check of a for loop

6 vues (au cours des 30 derniers jours)
gaia buratti
gaia buratti le 29 Juil 2011
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

Réponse acceptée

the cyclist
the cyclist le 29 Juil 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 commentaires
the cyclist
the cyclist le 29 Juil 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.
gaia buratti
gaia buratti le 1 Août 2011
Sorry for the delay in the acceptance of the answer, but I wasn't at home

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by