For loope small increments
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I cannot seem to find the solution to this problem. I write a for loop and i tell it to increment by a small value, but instead of starting at 1, it starts at 2.9110 here is the loop
for m=1:.001:4
m
end
does anyone know what its going on? i expect it to start at 1 and increment by .001 every time so that it goes 1.001, 1.002, 1.003 and so on thank you
0 commentaires
Réponse acceptée
Matt Fig
le 11 Mar 2011
I don't know why you think this starts at 2.910. Perhaps you are running into the limit of your command window when trying to scroll back up after running the loop. Do this:
for m=1:.001:4
m
pause(.5)
end
Now you should see m incrementing like you expect as it prints slowly out.
2 commentaires
Paulo Silva
le 11 Mar 2011
Matt that code might freak out someone who doesn't know how to stop it (CTRL+C in MSWIN OS)
Plus de réponses (4)
Paulo Silva
le 11 Mar 2011
It works fine here, try this
m=1:.001:4;
What's the first value of the vector m?
0 commentaires
marvin corado
le 11 Mar 2011
1 commentaire
Matt Fig
le 11 Mar 2011
Please select a best answer for this question, then start a new one. That way people can search Answers for a specific issue they are having.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!