Question: please write this code in matlab. 1. [Submit on zyLabs) Write a function that has one input, a square (n x n, for any integer

 please write this code in matlab. 1. [Submit on zyLabs) Writeplease write this code in matlab.
a function that has one input, a square (n x n, for

1. [Submit on zyLabs) Write a function that has one input, a square (n x n, for any integer n) matrix. It should return three outputs: D, A, and B. Every square matrix has a upper left to lower right diagonal. For instance, the following matrix: [1 2 3] 4 5 6 17 8 9 Has the diagonal: 5 5 9 Your first output, D, should be the diagonal of your input matrix, with all other numbers set to 0. In the above matrix, it would be: 11 001 0 5 0 Lo 09 A and B should be the numbers ABOVE and BELOW that diagonal, respectively, with all other numbers set to 0. For instance, A in the above example would be: TO 2 31 0 0 6 lo 0 0 And B would be: 07 4 0 0 17 8 0] 0 50 Lo 09 A and B should be the numbers ABOVE and BELOW that diagonal, respectively, with all other numbers set to 0. For instance, A in the above example would be: TO 2 31 0 0 6 Lo 0 0 And B would be: [0 0 07 4 0 17 8 0 We strongly recommend using nested loops to accomplish these tasks, though other answers will be accepted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!