How to add a "if not a number" expression to GUI error dialog
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
Hi, I'm making a GUI and is trying to add error dialogs to it. I have an input pressure P, and was wishing to set minimum and maximum boundaries for the GUI to either work or show error dialogs. However when I used P=NaN to make an expression for a non-numerical input (like P=apple where apple is not defined numerically) I got error messages telling me that "the expression to the left of the equals sign is not a valid target for an assignment". What could I do instead?
Here is my code:
P = str2num(get(findobj('tag','gP'),'string'));
if P>550.7921
elseif P<0
elseif P=NaN
errordlg('No solution','Error')
return
end
1 Commento
Stephen23
il 2 Mar 2018
As an aside: use str2double rather than str2num: this guarantees only numeric scalars in the output, and avoids the eval inside str2num.
Risposte (1)
if isnan(P)
errordlg('...');
end
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!