Question: MATLAB ASAP 5- [25 points) Write a function mat_corner that will receive an n x n matrix (i.e. a square matrix) as the input argument.
MATLAB ASAP
5- [25 points) Write a function "mat_corner" that will receive an n x n matrix (i.e. a square matrix) as the input argument. The function will return all the corner entries of the matrix and output them in a 1 x n row vector format. The function must work for any nxn matrices. An error message will be displayed in the command window if the user inputs a non-square matrix. Example 1 illustrates that if a 3 x 3 matrix A is passed in as the input of "mat_corner", after the function is executed in the command window, the corner entries (1 5 7 2) of A will be the output. Example 2 shows the case that the input matrix is not square, hence, an error massage is displayed. Example 1 >> A = [1 3 7; 8 0 3; 5 6 2]; >> mat_corner(A) ans = 1 5 7 2 Example 2 >> A = [1 3 7; 8 0 3]; >> mat_corner(A) Error, it is not a square matrix (NOTE: for-loop and while-loop are not allowed) 6- [10 points) Compute the product of odd integers from 10 to 50 by using loops in MATLAB. 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
