Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q4 Create a new Matlab m-file with the name diagonalSquared.m. You will write a script that builds a n n matrix A that is zero
Q4 Create a new Matlab m-file with the name diagonalSquared.m. You will write a script that builds a n n matrix A that is zero everywhere except along the diagonal, and on the diagonal, the i-th row has entry f. So, if n = 3, then A-1040 The script will have n as a parameter. So, in the first line of diagonalSquared.m, write n-3 (you can change the value of n later on). Your task is to fill out the rest of the script in order to build the matrix A. You must use for loops, and your for loops should involve n. If your code is working properly, and your script is saved in the Current Directory (see instructions previously described), you should be able to examine the matrix A by typing in the command line diagonalSquared (a) Give all the code inside your diagonalSquared.m file. b) The trace of a matrix is the sum of all of the diagonal entries of the matrix. (So, the trace of is 1 +4 = 5). What is the trace of the matrix A described above when n = 20? (The MATLAB function trace might be of use to you.) Also write down the commands you use to calculate this result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started