How can i determine error in matlab by using error loop without try catch or other loops?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ahmet ozdemir
am 30 Apr. 2016
Beantwortet: ahmet ozdemir
am 30 Apr. 2016
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 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 30 Apr. 2016
Bearbeitet: Azzi Abdelmalek
am 30 Apr. 2016
a=input('enter a number N','s')
b=str2num(a)
if isempty(b)
'Error'
'presse any key to cotinue'
pause
end
1 Kommentar
Walter Roberson
am 30 Apr. 2016
Bearbeitet: Walter Roberson
am 30 Apr. 2016
str2double would be better for restricting to numbers. you would check for nan rather than isempty
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!