MATLAB: Can you guys help me with the ASSIGNMENT? i just don’t know how to answer it =(

doit4mehomeworkmatrixno attempt

Can you teach my the codes of the attached problem in the picture? I will appreciate your help. thank you. =)

Best Answer

Method one: bsxfun
>> n = 5;
>> bsxfun(@plus,n:-1:0,(0:n)')
ans =
5 4 3 2 1 0
6 5 4 3 2 1
7 6 5 4 3 2
8 7 6 5 4 3
9 8 7 6 5 4
10 9 8 7 6 5
Method two: toeplitz
>> toeplitz(n:2*n,n:-1:0)
ans =
5 4 3 2 1 0
6 5 4 3 2 1
7 6 5 4 3 2
8 7 6 5 4 3
9 8 7 6 5 4
10 9 8 7 6 5