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 ifelse 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
a Write a script that determines the following sum using a While loop:
yii
b Write a UDF function, called qflipmatrix, 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 x matrix A:
A&&&@&&&@&&&@&&&
B&&&@&&&@&&&@&&&
Copy and paste the UDF code.
c Call the function, qflipmatrix, with the following input matrix C and obtain a new matrix D Show both C and D
C&&&@&&&
d Write a userdefined 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 qUDF.
For example, if input matrix A is
A&&@&&@&&
Then, the output matrix B will be
B&&@&&@&&
Copy and paste the UDF code.
e Use builtin Matlab function randi to generate a by random matrix E rows and columns that range from to the minimum number is and the maximum number is Test your function, qUDF, 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
