How to Limit input to a whole interger?
37 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2012-10-5
编辑:Azzi Abdelmalek
2012-10-5
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!