want to stop the value at certain value in for loop
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Geoff Hayes
2016-10-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 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!