Question: Loops and if - else / switch case question. You must create three . m files: two are UDF function files for step b and

Loops and if-else / switch case question. You must create three .m files: two are UDF function files for step b and d, and one is a script file that includes all steps from a to e.
(10 points) Write a script that determines the following sum using a While loop:
y=_(i=3)^10(3-2i)^2
(5 points) Write a UDF function, called q3flipmatrix, that has one input matrix A and one output matrix B. The function returns matrix B the same size as matrix A, but with the order of the elements reversed both in row and column. For example, for 4x4 matrix A:
A=[(1&2&3&4@5&6&7&8@9&10&11&12@13&14&15&16)]
B=[(16&15&14&13@12&11&10&9@8&7&6&5@4&3&2&1)]
Copy and paste the UDF code.
(5 points) Call the function, q3flipmatrix, with the following input matrix C and obtain a new matrix D. Show both C and D.
C=[(1&3&5&7@2&4&6&8)]
d - Write a user-defined function (UDF), with one input (matrix A) and one output (matrix B) such that all negative elements in matrix A are replaced with zero, and all positive elements in matrix A are replaced with square roots of the elements. You must use loops to create this UDF function. You may name the function q3UDF.
For example, if input matrix A is
A=[(-1&2&3@4&3&0@2&-9&4)]
Then, the output matrix B will be
B=[(0&1.414&1.732@2&1.732&0@1.414&0&2)]
Copy and paste the UDF code.
e - Use built-in Matlab function randi to generate a 3 by 3 random matrix E (3 rows and 3 columns) that range from -20 to 20(the minimum number is -20, and the maximum number is 20). Test your function, q3UDF, for this matrix E to obtain a new matrix F. Show both E and F.

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!