How to create large matrix with a pattern of sorts.
10 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Srivardhan Gadila
2020 年 9 月 30 日
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 件のコメント
madhan ravi
2020 年 9 月 30 日
Since your homework is to use a loop:
M = circshift(fliplr(tril(true(64))) .* [0; 1./(2:64).'], -1, 1);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!