Question: Given any square matrix M with even dimensions (2 by 2, 4 by 4, 6 by 6, and so on). a) Write a MATLAB function:

 Given any square matrix M with even dimensions (2 by 2,

Given any square matrix M with even dimensions (2 by 2, 4 by 4, 6 by 6, and so on). a) Write a MATLAB function: fold HM= fold H(M), that will return in matrix foldHM^- a matrix that is the horizontally folded version of M. both horizontal halves of M should be summed as shown below. Given the 4 by matrix M 1 -3 2 4 5 7 8 9 6 8 21 3 3 3 3 1 -3 2 4 5 7 8 9 6 8 2 1 3 3 3 3 Calling the function foldH(M) gives the horizontally folded, 2 by 4, matrix foldHM. 4 0 5 7 11 15 10 10 Vectorize your code as much as you can. Your code should work with nay matrix of even dimensions. b) Write a MATLAB function: foldV(M) that will return in matrix "foldVM" a matrix that is the vertically folded version of M. Both vertical halves of M should be summed as shown below Given the same 4 by matrix M 1 - 3 2 4 5 7 89 6 8 2 1 3 3 3 3 Calling the function fold V(M) gives the vertically folded, 4 by 2, matrix, fold VM. 3 1 13 16 8 9 6 6 Vectorize your code as much as you can. You code should work with any matrix of even dimensions

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!