Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2- Create a new script that is called HW11b.m and save it. The script will do th

ID: 2268759 • Letter: 2

Question

2- Create a new script that is called HW11b.m and save it. The script will do the following: a. Declare two variables row -5, col-6 b. Declare a (5x6) matrix called z with random entries using rand command i. You need to find the maximum value of the matrix using two nested for loops c. Initialize the maximum value MAX z(1,1). This initialization step is required d. Use two nested for loops to go over each element in z Test the value of each element using if statement such that if the new element in z is > MAX then MAX become the new element i. f (z(r,c) >MAX) MAX-z(r,c) end e. Outside the loops, test your algorithm using a built-in function called max such that MAXI= max(max(z)) Such that MAX1 and MAX should haue the came

Explanation / Answer

Matlab Script:

row = 5;col=6;
z = rand(row,col);
MAX = z(1,1);

%nested loop below
for r=1:row
for c=1:col
if z(r,c)>MAX
MAX = z(r,c);
end
end
end

MAX1 = max(max(z));
disp('MAX1');
disp(MAX1);
disp('MAX');
disp(MAX);

Command window output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote