- #1
elbarto
- 33
- 0
Hi all,
Can someone please help me with my MATLAB code. I am trying to get the program to quite if the user tries to input a non-numeric value, and will display an error message. I have got it to work useing the MATLAB input('promt','s') command, but i don't want to use this command because a user can't enter 5/100 etc.
Here is my code.
I would just like to know if there is a simply way to do this, if not I will use the command I used before and use the eval function I think...
Thank You
Regards Elbarto
Can someone please help me with my MATLAB code. I am trying to get the program to quite if the user tries to input a non-numeric value, and will display an error message. I have got it to work useing the MATLAB input('promt','s') command, but i don't want to use this command because a user can't enter 5/100 etc.
Here is my code.
Matlab:
j = input('number?:')
if isnan(j)==1
disp('Input must be a number, Function will terminate')
return
end
I would just like to know if there is a simply way to do this, if not I will use the command I used before and use the eval function I think...
Thank You
Regards Elbarto
Last edited by a moderator: