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!

 Respuesta aceptada

Star Strider
Star Strider el 13 de Jul. de 2014

1 voto

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 comentarios

Shashanka
Shashanka el 14 de Jul. de 2014
Thank you! It worked
Star Strider
Star Strider el 14 de Jul. de 2014
My pleasure!
Ian Ochavillo
Ian Ochavillo el 20 de Abr. de 2021
Hello can you also help me with my code 👉👈😔. I'm a newbie and I just really need help for a school project.
Star Strider
Star Strider el 20 de Abr. de 2021
@Walter RobersonThank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Jul. de 2014

Comentada:

el 20 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by