Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Problem with iterating loop again if output is less than some fixed value
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I am trying to calculate theta1, theta2 and r using following equations.
N=100;
for j=2:N
t(j)=t(j-1)+dt; %theta1, theta2 and r do not depend on time explicitly.
k=0.95;% input parameter
theta1(j)=theta1(j-1)+dt*k*(sin(theta2(j-1)-theta1(j-1))));
theta2(j)=theta2(j-1)+dt*k*(sin(theta1(j-1)-theta2(j-1))));
r(j)=Equation that depends on theta1 and theta2
At the middle of iteration if the value of r goes below some value say 0.5 then I want to use higher value of k(>0.95) and recalculate from the beginning using same equations given above.
I will be thankful for your help. Dharma
0 件のコメント
回答 (1 件)
Walter Roberson
2018 年 3 月 7 日
k = 0.95;
N = 100;
while true
did_all = true;
for j = 2 : N
t(j)=t(j-1)+dt; %theta1, theta2 and r do not depend on time explicitly.
theta1(j)=theta1(j-1)+dt*k*(sin(theta2(j-1)-theta1(j-1))));
theta2(j)=theta2(j-1)+dt*k*(sin(theta1(j-1)-theta2(j-1))));
r(j)=Equation that depends on theta1 and theta2
if r(j) < 0.5;
did_all = false;
break;
end
end
if did_all; break; end
k = k + 0.05;
end
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!