필터 지우기
필터 지우기

for loop

조회 수: 7 (최근 30일)
Kugen Raj
Kugen Raj 2012년 3월 22일
if size(qq)==[1,8]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
ff2=[(hh(1,1)+qq(1,6))];
ff3=[(hh(1,1)+qq(1,8))];
aa=kk(ff);
aa1=kk(ff1);
aa2=kk(ff2);
aa3=kk(ff3);
elseif size(qq)==[1,6] / size(qq)==[1,7]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
ff2=[(hh(1,1)+qq(1,6))];
aa=kk(ff);
aa1=kk(ff1);
aa2=kk(ff2);
elseif size(qq)==[1,4] / size(qq)==[1,5]
ff=[(hh(1,1)+qq(1,2))];
ff1=[(hh(1,1)+qq(1,4))];
aa=kk(ff);
aa1=kk(ff1);
elseif size(qq)==[1,2] / size(qq)==[1,3]
ff=[(hh(1,1)+qq(1,2))];
aa=kk(ff);
end
based on my coding, i want to calculate (aa-aa3) if the size(qq)=[1,8], (aa-aa2) if size(qq)=[1,6], (aa-aa1) of size(qq)=[1,4] and (aa only) if the size(qq)=[1,2]. Is this code correct because im not sure if it works properly.

답변 (1개)

Nathan Greco
Nathan Greco 2012년 3월 22일
The only thing that doesn't look right to me is where you have
elseif size(qq)==[1,#] / size(qq)==[1,#+1]
Where # is 6,4,2 Why do you have the second half there? I would get rid of that and just put
elseif size(qq)==[1,#]
And so on. Note: If you wanted to say if size(qq) is less than or equal to [1,3], you would need an | as such:
elseif size(qq)==[1,#] | size(qq)==[1,#+1]
-Nathan
  댓글 수: 2
Kugen Raj
Kugen Raj 2012년 3월 22일
how do I put it, if i want to calculate (aa-aa2) in the condition where size(qq)=[1,8] or size(qq)=[1,7]. i will have to put like size(qq)=[1,8] | size(qq)=[1,7] ?
Nathan Greco
Nathan Greco 2012년 3월 22일
Yes, just replace your /'s with |'s.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by