How to get only the last value in a 'while loop'?

Hi, I am stuck with a situation where the results are displayed every time the while loop is run. However, I want to be able to display and use only the last output of the while loop (i.e. the output just before the loop is exited) for further processing. Thanks in advance!

 Réponse acceptée

Star Strider
Star Strider le 13 Juil 2014

1 vote

You haven’t posted your code, so I’m making an educated guess here.
Put a semicolon ‘;’ at the end of the statement that is displaying in the loop. That will suppress the display without affecting the functions in the loop.
At the end of the loop, the last value of the variable will be the value stored in the variable.

5 commentaires

Shashanka
Shashanka le 14 Juil 2014
Thank you! It worked
Star Strider
Star Strider le 14 Juil 2014
My pleasure!
Hello can you also help me with my code 👉👈😔. I'm a newbie and I just really need help for a school project.
@Walter RobersonThank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by