How to get only the last value in a 'while loop'?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shashanka
le 13 Juil 2014
Commenté : Star Strider
le 20 Avr 2021
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!
0 commentaires
Réponse acceptée
Star Strider
le 13 Juil 2014
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
Plus de réponses (0)
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!