フィルターのクリア

Trying to see if a variable is an integer or not

2 ビュー (過去 30 日間)
Gianni Davies
Gianni Davies 2021 年 5 月 10 日
コメント済み: Gianni Davies 2021 年 5 月 11 日
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

採用された回答

per isakson
per isakson 2021 年 5 月 10 日
編集済み: per isakson 2021 年 5 月 10 日
Try this
%%
x=2.5;
answer = ( x == floor(x) )
answer = logical
0
  3 件のコメント
per isakson
per isakson 2021 年 5 月 10 日
Gianni Davies
Gianni Davies 2021 年 5 月 11 日
Cheers all of these work

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by