How do I write an if statement for if a variable is an integer, perform a function.

12 ビュー (過去 30 日間)
Temi O
Temi O 2019 年 2 月 27 日
コメント済み: Temi O 2019 年 3 月 1 日
Please, how do I say this? I want to perform a function if Var(i) is an integer?
for i = 1: 1000
Var(i+1) = Var(i) + 100e-4
if Var(i) % condition for if Var(i) is an integer (whole number). How do I write this?
%Perform a function
end
end

採用された回答

madhan ravi
madhan ravi 2019 年 2 月 27 日
編集済み: madhan ravi 2019 年 2 月 27 日
if ~rem(Var(i),1)
  5 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 27 日
Oopsie thanks steven! So rem() should do the job.
Temi O
Temi O 2019 年 3 月 1 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by