How can i determine error in matlab by using error loop without try catch or other loops?
1 次查看(过去 30 天)
显示 更早的评论
My code only includes numbers. If someone donot gives a numbers in input, this code shows screen like ERROR but code should continue to work Thanks,
0 个评论
采纳的回答
Azzi Abdelmalek
2016-4-30
编辑:Azzi Abdelmalek
2016-4-30
a=input('enter a number N','s')
b=str2num(a)
if isempty(b)
'Error'
'presse any key to cotinue'
pause
end
1 个评论
Walter Roberson
2016-4-30
编辑:Walter Roberson
2016-4-30
str2double would be better for restricting to numbers. you would check for nan rather than isempty
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!