Hi guys, I would like to be sure that this for loop is correct.
B(:,:)=1./((m-1)*(mu0*tc-Wsim(:,:))).^(1/(m-1));
dB=B(2:end,:)-B(1:end-1,:);
for n=1:N
for t=1:steps-1
if abs(mu(t,n)./k)>uninum2;
B(t,n)=B(t,n).*(1-k);
%elseif abs(mu(t,:))*(1/k)>1;
% B(t,:)=B(t,:).*(1-k);
else
B(t,n)=1./((m-1)*(mu0*tc-Wsim(t,n))).^(1/(m-1));
B(t,n)=real(B(t,n))+imag(B(t,n));
end
B(t+1,n)=B(t,n)+dB(t,n);
end
end
When the loop restart, the B(t,n) that considers is the output of B(t+1,n) right? If not How can I build a loop that does something like that? thanks in advance
Gaia

 채택된 답변

the cyclist
the cyclist 2011년 7월 29일

0 개 추천

If I understand your question correctly, then the answer is yes, the loop does what you want.
More imporantly, this should be easy for you to check yourself. You can use the debugging commands (type "doc debug" to see them) to stop your code inside the loop, and see that the variables are doing what you expect.

댓글 수: 3

gaia buratti
gaia buratti 2011년 7월 29일
fantastic!!! do I have to type it in the command window right?
Thanks a lot
the cyclist
the cyclist 2011년 7월 29일
The easy way:
Inside the editor, next to the line numbers, is a small dash. Click on that dash to place a breakpoint. (It will show up as a red disk.) Click again to remove.
Also, since you found this answer helpful, you may want to "accept" it, so that future users know that.
gaia buratti
gaia buratti 2011년 8월 1일
Sorry for the delay in the acceptance of the answer, but I wasn't at home

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

추가 답변 (0개)

카테고리

도움말 센터File 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