Getting a increasing by the nxn matrix inside a for loop

조회 수: 2 (최근 30일)
Mark Loui
Mark Loui 2021년 3월 18일
댓글: KSSV 2021년 3월 18일
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일
n=100 ;
matrixA = cell(n,1) ;
for i=1:n
matrixA{i} = rand(n) ;
end
  댓글 수: 6
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개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by