Effacer les filtres
Effacer les filtres

Waitbar error during calculation

12 vues (au cours des 30 derniers jours)
john
john le 9 Mar 2014
Commenté : john le 18 Mar 2014
Hello,
if I press button "x"- that I want to close waitbar for example during for i=1:a during calculation, I got error, why?
The second argument must be a message string or a handle to an existing waitbar.
Error in ==> Simulator>pushbutton5_Callback at 2543
waitbar(step/steps,calculation,sprintf([calculation,' %d%%
...'],round(step/steps*100)));
This is my code:
calculation = waitbar(0,'Calculation...','Name','Status of calculation');
for i=1:a;
step = 1+step;
waitbar(step/steps,calculation,sprintf([actual caltulation,' %d%%...'],round(step/steps*100)));
end;
for i=1:b;
step = 1+step;
waitbar(step/steps,calculation,sprintf([actual caltulation,' %d%%...'],round(step/steps*100)));
end;
for i=1:c;
step = 1+step;
waitbar(step/steps,calculation,sprintf([actual caltulation,' %d%%...'],round(step/steps*100)));
end;

Réponse acceptée

Image Analyst
Image Analyst le 9 Mar 2014
It was not expecting you to close it after you set it up and tried to use it again. To avoid the error message, wrap the call to waitbar in a try catch
try
waitbar(step/steps,calculation,sprintf([actual caltulation,' %d%%...'],round(step/steps*100)));
catch
% Don't do anything in the catch, just ignore the error.
end
  1 commentaire
john
john le 18 Mar 2014
Is there possible to disable button "x"?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by