Displaying error messages on a MATLAB GUI
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi there, I just have a general question about MATLAB GUIs: is it possible to display error messages within an 'edit' text box? For example, if I have a simple GUIDE-generated GUI which runs code when a pushbutton is pressed, I know that I can use 'edit' text boxes to put in mathematical values ( the 'input boxes').
If I was to put a word instead of a number into the input boxes, I know that there will be an error displayed on the MATLAB command window-however, is there a line of code which would allow me to display this message (or another message) in the input boxes, if the pushbutton were to be pressed?
Any suggestion would be most helpful!
-Nathan.
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 11월 4일
You'll need to use try-catch to catch a possible error and then use lasterr() to get the error message. Check the documentation for these functions in your version of MATLAB as they might have been changed.
try
a=1/'abc';
catch
ErrorMessage=lasterr;
disp(ErrorMessage);
end
댓글 수: 0
추가 답변 (2개)
Jan
2011년 11월 4일
To be exact, you can display strings in an edit field only, and not numbers. Therefore you can easily display an error message in such a control.
If you get an error message, please post the complete message here together with the corresponding code.
댓글 수: 0
Sreeram Mohan
2011년 11월 7일
Using
try
catch E
end
and using message ID from 'E' or message would give more control on error management.
--sreeram
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!