How to create large matrix with a pattern of sorts.
8 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Srivardhan Gadila
on 30 Sep 2020
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
0 Comments
madhan ravi
on 30 Sep 2020
Since your homework is to use a loop:
M = circshift(fliplr(tril(true(64))) .* [0; 1./(2:64).'], -1, 1);
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!