Effacer les filtres
Effacer les filtres

want to stop the value at certain value in for loop

3 vues (au cours des 30 derniers jours)
abdalrhman hassan
abdalrhman hassan le 22 Oct 2016
Commenté : Geoff Hayes le 23 Oct 2016
hey guys when i run the program it keep show me the negative value and i only want it the positive and less error thank you

Réponse acceptée

Geoff Hayes
Geoff Hayes le 22 Oct 2016
abdalrhman - if you want to exit out of your loop once the tolerance is less than zero, then put in a condition to do so
for EJ=EJ+.015:.01:E1-.01
Q1=sqrt((E1-EJ)/R1);
Q2=sqrt(abs((E2-EJ))/R2);
Q3=sqrt((EJ-E3)/R3);
tol=Q1-Q2-Q3l
EJ;
if tol < 0
break; % exit loop since tolerance is now negative
end
tolnew=tol;
end
  1 commentaire
Geoff Hayes
Geoff Hayes le 23 Oct 2016
abdalrhman's answer moved here
Thank you that was helpful :D

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

Community Treasure Hunt

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

Start Hunting!

Translated by