필터 지우기
필터 지우기

What changes do i need to make so my matrix is not overwritten?

조회 수: 1 (최근 30일)
A K
A K 2016년 10월 18일
편집: Walter Roberson 2016년 10월 18일
I have the following code it runs fine, note where i=1; i want to change it to i=1:3, but i want to store the individual 3 matrices separately. What changes should i make?
Z=ones(n,no_of_stages);
for i=1;
for k=1:no_of_stages
M(k,k)=diag(-phi(i,k));
for d=2:no_of_stages
M(d,d-1)=diag(abs_coeff(i,d));
for r=1:no_of_stages-1;
M(r,r+1)=diag(Z(i,r));
end
end
end
end

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 18일
Use a cell array indexed by i
  댓글 수: 2
A K
A K 2016년 10월 18일
The code creates a tri-diagonal matrix, do u mean i should ad another line saying M(i)=M??? so M(1) is the first matrix, M(2) is the second.
Walter Roberson
Walter Roberson 2016년 10월 18일
편집: Walter Roberson 2016년 10월 18일
Z=ones(n,no_of_stages);
for i=1;
clear tM
for k=1:no_of_stages
tM(k,k)=diag(-phi(i,k));
for d=2:no_of_stages
tM(d,d-1)=diag(abs_coeff(i,d));
for r=1:no_of_stages-1;
tM(r,r+1)=diag(Z(i,r));
end
end
end
M{i} = tM;
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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