Question: IN MATLAB Write a function to accept a matrix m and a number flag, trim and return a matrix as in the following examples. If

IN MATLAB
Write a function to accept a matrix m and a number flag, trim and return a matrix as in the following
examples. If m is a square matrix, return m as is. If m is not itself square: then return the top square or
the left square when flag 0; or return the bottom square or the right square when flag 0. Examples:
Input m=
and flag=1, would return:
9,10,3
10,7,6
2110(flag>=0, left square, trim off the remaining part).
Input same m as above but flag=-1 would return:
3,10,10
6,2,5
10109(as flag not 0, right square).
Input m=
1,10,13
9,9,13
8,13,4
15,14,3
16,15,10
4,6,19
and flag=-1 would return:
15,14,3
16,15,10
4619(bottom square as flag not 0).
Hints: might need some careful algebra on the row number and column number.
THIS MUST BE DONE IN MATLAB
IN MATLAB Write a function to accept a matrix m

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 Programming Questions!