필터 지우기
필터 지우기

How to save values of loops ?

조회 수: 2 (최근 30일)
Fox
Fox 2016년 1월 4일
댓글: Fox 2016년 1월 4일
I made the following for loop and now want to save the different values I get on my command window in one vector: My Problem is that the following code doesn't work.
be=zeros(16,1);
for s=1:2:16
bety1=((z3(0+s:1+s,1:20)*z3(0+s:1+s,1:20)')^-1)*(z3(0+s:1+s,1:20)*y3(1:20));
be(s)=bety1
end
Can somebody help me ? Perhaps you need the info that at every bety1 I get a vector with 2 rows so in the end I should have a vektor with 16 rows.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 1월 4일
be=zeros(16,1);
for s=1:2:16
bety1=((z3(0+s:1+s,1:20)*z3(0+s:1+s,1:20)')^-1)*(z3(0+s:1+s,1:20)*y3(1:20));
be(s:s+1)=bety1
end
  댓글 수: 1
Fox
Fox 2016년 1월 4일
Thanks. Could you perhaps help me with the following similar problem ? Here I want to do the same but with the double for loop it doesn't work. End should be a matrix with 16 rows and 41 colums.
bee=zeros(16,41)
for i=1:41
for k=1:2:16
bety2=((z3(0+k:1+k,1+i:20+i)*z3(0+k:1+k,1+i:20+i)')^-1)*(z3(0+k:1+k,1+i:20+i)*...
y3(1+i:20+i));
bee(k:k+1,i:i+1)=bety2
end
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by