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

7 visualizaciones (últimos 30 días)
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

Respuesta aceptada

madhan ravi
madhan ravi el 27 de Feb. de 2019
Editada: madhan ravi el 27 de Feb. de 2019
if ~rem(Var(i),1)
  5 comentarios
madhan ravi
madhan ravi el 27 de Feb. de 2019
Oopsie thanks steven! So rem() should do the job.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by