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

조회 수: 6 (최근 30일)
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by