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

Using MATLAB: Create a nested for-loop script to iterate through all values of i

ID: 3145164 • Letter: U

Question

Using MATLAB: Create a nested for-loop script to iterate through all values of i=1:12 and j=1:12. Also start with a running tally of total=0. At each iteration, check the value of j. If j is divisible by 4, then do nothing and proceed to the next value of j using the continue method. Next, if i*j is divisible by 5, then stop processing the current j-based for-loop using the break method, and move on to the next value of i. If both conditions have not been met, then add both i and j to the running tally called total. What is your final value for total at the end of your script?

Explanation / Answer

total=0;
for i=1:12
for j=1:12
if mod(j,4)==0
continue;
end
if mod(i*j,5)==0
break;
end;
total=total+i+j;
end
end
%Print
total

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