Effacer les filtres
Effacer les filtres

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

12 vues (au cours des 30 derniers jours)
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

Réponse acceptée

madhan ravi
madhan ravi le 27 Fév 2019
Modifié(e) : madhan ravi le 27 Fév 2019
if ~rem(Var(i),1)
  5 commentaires
madhan ravi
madhan ravi le 27 Fév 2019
Oopsie thanks steven! So rem() should do the job.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by