How to write repeating questions
5 次查看(过去 30 天)
显示 更早的评论
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
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
2021-4-8
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.
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!