Filter löschen
Filter löschen

try/catch in gui

11 Ansichten (letzte 30 Tage)
anahita
anahita am 1 Jul. 2013
Hi
I am a

Akzeptierte Antwort

Image Analyst
Image Analyst am 1 Jul. 2013
Bearbeitet: Image Analyst am 1 Jul. 2013
Just put it in a while loop until they get it right. Warn them like this:
message = sprintf('Error: you entered %d when you should have entered a number in the range [0,99].', theirNumber);
uiwait(warndlg(message));
In general for a try/catch you can try this:
function blahblahblah()
try
% Some code that generates an error.
catch ME
message = sprintf('Error in blahblahblah():\n%s', ME.message);
uiwait(warndlg(message));
end

Weitere Antworten (1)

Pourya Alinezhad
Pourya Alinezhad am 1 Jul. 2013
just check the input box you created in GUI for numbers below desired value.if input number was bigger than upper bound you can call a error message box GUI.

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by