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(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site