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!