Question: Please use matlab ANONYMOUS FUNCTIONS (a) Define an anonymous function rowSums which calculates the row sums of a matrix of any dimension. Then define magicMath

Please use matlab ANONYMOUS FUNCTIONS (a) Define an anonymous function rowSums whichPlease use matlab

ANONYMOUS FUNCTIONS (a) Define an anonymous function rowSums which calculates the row sums of a matrix of any dimension. Then define magicMath and magicMat7 to be a 5 x 5 and a 7 x 7 magic square matrix, respectively. Compute magicMat5RowSums by calling rowSums(magicMat5), and compute magicMat7RowSums by calling rowSums (magicMat7). (b) Define anonymous functions f and g, where f(1) = r ln(2) and g(y) = yey. Create another anonymous function h by composing f and g, i.e., h(z) = g(f(z)). Use linspace to define a column vector z, of which the range is from 1 to 5 with 11 entries. Evaluate function h at z, and assign the result to hz. (c) Define an anonymous function matProd for calculating the product of two matrices, that is, mat Prod(A,B) = ABBT AT. Define A and B using colon, reshape and transpose as follows, 7 10 13 16 2 3 A= ,B= 8 11 14 17 4 5 6 9 12 15 18 - Store the result of mat Prod(A, B) to matProdAB. (d) Define an anonymous function p, where 23 if r 1. Next visualize p(x) using fplot on [-2, 2] (Use help fplot for more details about fplot). Then run print(gcf, '-dpng', 'lab_03_13.png') to save the plot to a .png file. ANONYMOUS FUNCTIONS (a) Define an anonymous function rowSums which calculates the row sums of a matrix of any dimension. Then define magicMath and magicMat7 to be a 5 x 5 and a 7 x 7 magic square matrix, respectively. Compute magicMat5RowSums by calling rowSums(magicMat5), and compute magicMat7RowSums by calling rowSums (magicMat7). (b) Define anonymous functions f and g, where f(1) = r ln(2) and g(y) = yey. Create another anonymous function h by composing f and g, i.e., h(z) = g(f(z)). Use linspace to define a column vector z, of which the range is from 1 to 5 with 11 entries. Evaluate function h at z, and assign the result to hz. (c) Define an anonymous function matProd for calculating the product of two matrices, that is, mat Prod(A,B) = ABBT AT. Define A and B using colon, reshape and transpose as follows, 7 10 13 16 2 3 A= ,B= 8 11 14 17 4 5 6 9 12 15 18 - Store the result of mat Prod(A, B) to matProdAB. (d) Define an anonymous function p, where 23 if r 1. Next visualize p(x) using fplot on [-2, 2] (Use help fplot for more details about fplot). Then run print(gcf, '-dpng', 'lab_03_13.png') to save the plot to a .png file

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!