필터 지우기
필터 지우기

matrix index (I tried to name a matrix to use in a loop like variables.)

조회 수: 1 (최근 30일)
Sakunrat Jaejaima
Sakunrat Jaejaima 2015년 7월 24일
댓글: Sakunrat Jaejaima 2015년 7월 24일
I tried to name a matrix to use in a loop like variables.
forexample A(1)=[1 2;3 4]
A(2)=A(1)*2
A(3)=A(2)*2
.
.
.
A(j)=A(j-1)*2
But I can't use the notation A(j) in the loop. what should I call the j of A?

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 24일
편집: Azzi Abdelmalek 2015년 7월 24일
You can use cell arrays
A=cell(1,4)
A{1}=[1 2;3 4]
for k=2:numel(A)
A{k}=A{k-1}*2
end

Andrei Bobrov
Andrei Bobrov 2015년 7월 24일
A=[1 2;3 4];
jj=9;
A = bsxfun(@times,A,2.^reshape(0:jj-1,1,1,[]));

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by