How to Limit input to a whole interger?

36 visualizaciones (últimos 30 días)
Michael  Kurniawan
Michael Kurniawan el 5 de Oct. de 2012
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?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 5 de Oct. de 2012
Editada: Azzi Abdelmalek el 5 de Oct. de 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

Más respuestas (0)

Categorías

Más información sobre NaNs en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by