Reputation: 5789
[st,message] = system(cmd);
while st~=false
[st,message] = system(cmd);
end
In the case where st
is always false , I stuck in a loop for ever which is't good !
how could I improve that by adding a threshold a break ?
any suggesion ?
Thanks,
Upvotes: 0
Views: 56
Reputation: 4336
t=rem(now,1);
[st,message] = system(cmd);
while st~=false
[st,message] = system(cmd);
if rem(now,1)-t > 0.0001
break
end
end
Since the condition is not that important to you that you consider break
after a while, you can also try this,
[st,message] = system(cmd);
if st~=false
pause(2);
end
[st,message] = system(cmd);
Upvotes: 0
Reputation: 7975
count = 1;
while st~=false && count < 1000
[st,message] = system(cmd);
count = count + 1;
end
Upvotes: 2