Trying to see if a variable is an integer or not
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gianni Davies
am 10 Mai 2021
Kommentiert: Gianni Davies
am 11 Mai 2021
x=2.5;
isaninteger = @(x)isfinite(x)
x=floor(x)
answer=isaninteger(x)
I want the answer here to show that x is not an integer but all it shows is answer = 1. No idea how to fix this
The correct output here would be answer = 0
0 Kommentare
Akzeptierte Antwort
per isakson
am 10 Mai 2021
Bearbeitet: per isakson
am 10 Mai 2021
Try this
%%
x=2.5;
answer = ( x == floor(x) )
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots 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!