How to create large matrix with a pattern of sorts.

I wish to create a 64x64 matrix with a patern so it has like 62 0's and 2 1/2's in the 1st row and then 61 0's and 3 1/3's in the 2nd to the 7th, etc. In the worksheet, i was hinted towards using for loops

Answers (2)

Refer to MATLAB Onramp to get started with MATLAB.
The following code might help you:
s = 64;
m = zeros(s,s);
for i = 2:64
m(i-1,s-i+1:end) = 1/i;
end
Since your homework is to use a loop:
M = circshift(fliplr(tril(true(64))) .* [0; 1./(2:64).'], -1, 1);

Asked:

on 26 Sep 2020

Answered:

on 30 Sep 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!