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

Using MATLAB Use a for or while Loop to create an n × m matrix, in which: à The

ID: 3917570 • Letter: U

Question

Using MATLAB Use a for or while Loop to create an n × m matrix, in which: à The first row elements should get values equal to the number of their respective column. à The values for the elements in the first column should be the number of their respective row. (10) à The rest of the elements get values equal to the sum of the element just above them and the element to their left. The following example shows a created matrix. (30 points)

1 2 3 4 5 6

2 4 7 11 16 22

3 7 14 25 41 63

4 11 25 50 91 154

Explanation / Answer

n = 4;

m = 6;

M = zeros(n,m);

for c = 1:m

M(1,c) = c;

end

for d = 1:n

M(d,1) = d;

end

for i = 2:n

for j = 2:m

M(i,j) = M(i, j-1) + M(i-1,j)

end

end

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