Exit code

12 views (last 30 days)
Muhammad Arsalan
Muhammad Arsalan on 6 Apr 2011
Hi,
Can anyone help me with following:
cntr1 and cntr2 are 2 counter.
I want something like
if cntr1 == cntr2
exit the code (here i need help how to exit?)
uiwait(msgbox('Error!'));
end
Thanks in advance for help.
Kind regards. \\ Arsalan

Accepted Answer

Walter Roberson
Walter Roberson on 6 Apr 2011
Why are you exiting the code before you present the Error box?
Why are you using msgbox() instead of errordlg() ?
Do you want Matlab as a whole to EXIT, or do you want to RETURN to whatever routine might have called the present one, or do you want to create an ERROR condition that throws the program back to the command prompt unless something CATCHes the error?
  1 Comment
Muhammad Arsalan
Muhammad Arsalan on 6 Apr 2011
I just want to stop MATLAB from running the code if that condition is true. So i have tried "return" and it seems to work well.
if cntr1 == cntr2
uiwait(msgbox('Error!'));
return;
end
Thanks a lot for quick reply.
Best Reards, Arsalan

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!