Write a matlab loop that results in the following output 12
Write a matlab loop that results in the following output:
1^2 = 1
2^2 = 4
3^2 = 9
4^2 = 16
Solution
num = 2
for i = [1:4] #for loop executes from 1 to 4
fprintf(\'%d^%d = %d\ \',i,num,i*i); #multiplication table
end
Output:
1^2 = 1
2^2 = 4
3^2 = 9
4^2 = 16
![Write a matlab loop that results in the following output: 1^2 = 1 2^2 = 4 3^2 = 9 4^2 = 16Solutionnum = 2 for i = [1:4] #for loop executes from 1 to 4 fprintf(\ Write a matlab loop that results in the following output: 1^2 = 1 2^2 = 4 3^2 = 9 4^2 = 16Solutionnum = 2 for i = [1:4] #for loop executes from 1 to 4 fprintf(\](/WebImages/45/write-a-matlab-loop-that-results-in-the-following-output-12-1140613-1761611667-0.webp)