I'm looking to loop questions continuously until I get a 'no' answer.
For example when the program asks if there are any more rooms and I answer yes then it should ask the dimensions. And once I have inputted that then it should ask if there are anymore rooms, and so on until I say there aren't anymore rooms.

댓글 수: 1

Adam Danz
Adam Danz 2021년 4월 13일
> [flag] This is no longer appropriate and I would like it deleted so I no longer receive notifications/help.
In the upper left corner, click "unfollow" to stop receiving notifications on this thread.

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

 채택된 답변

Adam Danz
Adam Danz 2021년 4월 8일

1 개 추천

I assume you're using input to prompt users to respond. This is the least robust, most error-prone method of getting information from users.
I suggest using a question dialog box. For example: [see this answer].
To address your question, you can wrap the input command in a while-loop that continually saves the user's response and exits when the user enters 'no'.

댓글 수: 2

William Ward
William Ward 2021년 4월 9일
I am using a questdlg like you suggested. I am just new to matlab and don't understand which part you put the while loop on. I have attached what the flowchart should look like and what I have done so far.
Adam Danz
Adam Danz 2021년 4월 12일
편집: Adam Danz 2021년 4월 13일
I would create a simple, short while-loop that merely asks "are there any more floors" followed by a conditional statement that calls a "YES" routine and a "NO" routine.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

질문:

2021년 4월 8일

댓글:

2021년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by