How I can stop this code with the bukle 'WHILE'?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a problems to stop the buckle while, the condition RK1>RK2 works.But the buckle while, I dont know what is wrong in the code because its not stop (is running all time)
thanks!
function lanzar_2(name)
filename= strcat(num2str(name));
runCommand=strcat('abaqus job=',filename);
[runStatus,runCmdout]=dos(runCommand);
pause(20);
% Rk2=0;
while 1
pause(5)
[Rk,XL41L400,F1]=Lecturas_abaqus(name) %Lectura del archivo STA
for i=2:length(F1)
RK2=F1(i,1);
RK1=F1(i-1);
if RK1>RK2
killCommand=strcat('abaqus job=',filename,32,'terminate');
[killStatus,killCmdout]=dos(killCommand);
break
end
end
end
end
0 件のコメント
採用された回答
Yazan
2021 年 7 月 12 日
When the condition RK1>RK2 becomes satisfied, the code breaks the for loop and returns the while loop, which is always satisfied as your condition is while 1. If you require your code to break from the for and while loops when the condition is satisfied, you can use the following:
function lanzar_2(name)
filename= strcat(num2str(name));
runCommand=strcat('abaqus job=',filename);
[runStatus,runCmdout]=dos(runCommand);
pause(20);
% Rk2=0;
var = 1;
while var
pause(5)
[Rk,XL41L400,F1]=Lecturas_abaqus(name) %Lectura del archivo STA
for i=2:length(F1)
RK2=F1(i,1);
RK1=F1(i-1);
if RK1>RK2
killCommand=strcat('abaqus job=',filename,32,'terminate');
[killStatus,killCmdout]=dos(killCommand);
var = 0;
break
end
end
end
end
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!