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!