I want to throw the error that comes with entering a non number in a numeric only input
15 次查看(过去 30 天)
显示 更早的评论
n = input('Please enter a number:\n');
I get this error and I want to throw it and write another error:
Error using input
Unrecognized function or variable 'k'.
Error in eer (line 1)
n = input('Please enter your name:\n');
0 个评论
采纳的回答
Wan Ji
2021-8-30
n = str2num(input('Please enter a number:\n','s'));
if(isempty(n))
error('You are entering a non number in a numeric only input')
end
10 个评论
Wan Ji
2021-8-30
n = input('Please enter a number:\n','s');
if(isempty(n))
error('You are entering nothing')
elseif(isempty(str2num(n)))
error('You are entering a non number in a numeric only input')
end
n = str2num(n);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!