Getting a increasing by the nxn matrix inside a for loop

HI there i dont quite understand how to get a matrix that is increasing by nxn matrix
like for example
n=100
for i=1:n
matrixA=[1x1] matrix
iter1
matrixA=[2x2] matrix
iter 2
and so on until the 100x100 matrix, so
end
it would also help if the matrix i get can be used for the diag function?
Help is appreciated thank you in advance

 採用された回答

KSSV
KSSV 2021 年 3 月 18 日
編集済み: KSSV 2021 年 3 月 18 日

0 投票

n=100 ;
matrixA = cell(n,1) ;
for i=1:n
matrixA{i} = rand(n) ;
end

6 件のコメント

Mark Loui
Mark Loui 2021 年 3 月 18 日
Hi could you please further explain a bit on the code please?
Mark Loui
Mark Loui 2021 年 3 月 18 日
And how can it be implemented into the diag function, or creating a diagonal matrix?
Mark Loui
Mark Loui 2021 年 3 月 18 日
Also i have run your code, from the output there is still a 0x0 matrix at the bottom there, hence it is not possible for me to go on with the next step, any other method you could recommend?
KSSV
KSSV 2021 年 3 月 18 日
Read about rand, it is used to create a random numbers.
To get diaogonal matrices...read about diag.
Mark Loui
Mark Loui 2021 年 3 月 18 日
Ok then can i ask how to fill up the matrix with any values
KSSV
KSSV 2021 年 3 月 18 日
That any is random....
n=100 ;
matrixA = cell(n,1) ;
for i=1:n
matrixA{i} = rand*diag(repmat(i,1,i)) ;
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

質問済み:

2021 年 3 月 18 日

コメント済み:

2021 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by