Question: Make nxn diagonal matrices (n given in a variable) whose diagonal values are 1 to n. (Note: Do not use the diag function for
Make nxn diagonal matrices (n given in a variable) whose diagonal values are 1 to n. (Note: Do not use the diag function for this exercise. First determine the linear indices of the diagonal elements, and then assign 1:n to them. For the linear indices, you can compute them directly, or you can use the function sub2ind.) Example for n=5:
Step by Step Solution
There are 3 Steps involved in it
Sure you can create an nxn diagonal matrix in MATLAB without using the di... View full answer
Get step-by-step solutions from verified subject matter experts
