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

조회 수: 8 (최근 30일)
Shashanka
Shashanka 2014년 7월 13일
댓글: Star Strider 2021년 4월 20일
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!

채택된 답변

Star Strider
Star Strider 2014년 7월 13일
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
Star Strider
Star Strider 2021년 4월 20일
@Walter RobersonThank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by