필터 지우기
필터 지우기

how to input multiple items given a prompt?

조회 수: 10 (최근 30일)
cgo
cgo 2018년 9월 19일
편집: dpb 2018년 9월 19일
So far I only have worked with prompts giving one numerical response. (For example, input number: 10). That's it. Right now, I want to work with multiple inputs in a prompt, store them, and use them later. For example:
Enter your favourite numbers: 10, 25, 34 (maybe more than this, or even less than this).
Please let me know how to do this.
Thanks

채택된 답변

dpb
dpb 2018년 9월 19일
편집: dpb 2018년 9월 19일
You can input whatever you wish at the prompt as long as it's a valid ML expression.
>> input('?')
?[2, pi, sqrt(10)]
ans =
2.0000 3.1416 3.1623
>>
Of course, you need to give your users a clue as to what it is you're expecting from them! :)
And also be prepared to handle whatever it is they give you.
There are other input options besides just input to give more control over the interaction.
Look at inputdlg for example.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by