try/catch in gui

12 次查看(过去 30 天)
anahita
anahita 2013-7-1
Hi
I am a

采纳的回答

Image Analyst
Image Analyst 2013-7-1
编辑:Image Analyst 2013-7-1
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

更多回答(1 个)

Pourya Alinezhad
Pourya Alinezhad 2013-7-1
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by