How I can stop this code with the bukle 'WHILE'?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Yazan
le 12 Juil 2021
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
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!