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

Using Matlab: 2- Create a new script that is called HW11b.m and save it. The scr

ID: 2268749 • Letter: U

Question

Using Matlab:

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-(1,1). This initialization step is required. d. Use two nested for loops to go over each element in z i. 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. 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 MAX1- max(max(z)) Such that MAX1 and MAX should have the same value.

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);

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