how to run iterations?

69 vues (au cours des 30 derniers jours)
Oluyemi Jegede
Oluyemi Jegede le 6 Fév 2014
Commenté : Oluyemi Jegede le 6 Fév 2014
Please I need help with iterations. For instance, if my Matlab script runs thus:
z=2; z=1+z
What can i do if i am looking to run this a hundred times such that the result from '1+z' is put in place of Z upon every iteration. Thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Fév 2014
z=2;
for K = 1 : 100
z=1+z
end
  1 commentaire
Oluyemi Jegede
Oluyemi Jegede le 6 Fév 2014
thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Elvin
Elvin le 6 Fév 2014
You can try something like this:
z = 0;
for i = 1:100
z = z+i;
end
  2 commentaires
Walter Roberson
Walter Roberson le 6 Fév 2014
Notice this is "z+i" (lower-case I) not "z+1" (digit one)
Oluyemi Jegede
Oluyemi Jegede le 6 Fév 2014
thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by