How to Limit input to a whole interger?
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi Im trying to tell matlab to only allow input for whole numbers only i.e no numbers such as 23.4. How do I do this? also by doing this do I also stop any inputs that are imaginary?
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 5 Okt. 2012
Bearbeitet: Azzi Abdelmalek
am 5 Okt. 2012
test=0
while test==0
a=input('enter integer number')
if fix(a)-a==0
test=1
else
disp('Only integer numbers are allowed')
end
end
1 Kommentar
Walter Roberson
am 5 Okt. 2012
while mod(a,1)
can be used to replace
while fix(a)-a~=0
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!