Getting a increasing by the nxn matrix inside a for loop

2 views (last 30 days)
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

Accepted Answer

KSSV
KSSV on 18 Mar 2021
Edited: KSSV on 18 Mar 2021
n=100 ;
matrixA = cell(n,1) ;
for i=1:n
matrixA{i} = rand(n) ;
end
  6 Comments
Mark Loui
Mark Loui on 18 Mar 2021
Ok then can i ask how to fill up the matrix with any values
KSSV
KSSV on 18 Mar 2021
That any is random....
n=100 ;
matrixA = cell(n,1) ;
for i=1:n
matrixA{i} = rand*diag(repmat(i,1,i)) ;
end

Sign in to comment.

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!