check of a for loop
6 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
the cyclist
on 29 Jul 2011
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 Comments
the cyclist
on 29 Jul 2011
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.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!