Displaying an error message a non-numerical input is inputted in GUI
显示 更早的评论
To be more clear, I'm trying to use GUI in MATLAB for a project. In this project I want the user to input numbers, but if they input a character (like 'a' or 'b', or 'djos') I want there to be an error message to pop up.
Currently I am using:
m = get(handles.filter);
if ~ischar(m)
errordlg('ERROR: Input must be numerical.')
end
I've also used commands "error" and "msgbox", as well as "isnumeric" and "isstring" to no avail. I can get the error message to pop up just fine, however it even gives me the error message for fractions or numbers like "1" and "1/4"!
What am I doing wrong?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!