How to create large matrix with a pattern of sorts.

10 ビュー (過去 30 日間)
Shyaam Shankar
Shyaam Shankar 2020 年 9 月 26 日
回答済み: madhan ravi 2020 年 9 月 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

回答 (2 件)

Srivardhan Gadila
Srivardhan Gadila 2020 年 9 月 30 日
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

madhan ravi
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);

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by