Problem with isinteger() - how to determine whether a constant is integer?

1 回表示 (過去 30 日間)
Amit Kumar
Amit Kumar 2013 年 2 月 21 日
コメント済み: Walter Roberson 2017 年 8 月 10 日
Hi, I have problem with isinteger() function. I wrote following function:
function [x] = f1(n)
b=ininteger(n);
end
This is a partial code. I want to accept integer n to function f1. Whenever user inputs integers, such as 3 or 4, b = 0 as Matlab treats constants as double. I tried converting n to int8(), but then floating value also gets converted to integer. How to test whether input constant is an integer or not? Thanks.

採用された回答

José-Luis
José-Luis 2013 年 2 月 21 日
a == floor(a)

その他の回答 (1 件)

Prasanta Saikia
Prasanta Saikia 2017 年 8 月 10 日

製品

Community Treasure Hunt

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

Start Hunting!

Translated by