필터 지우기
필터 지우기

Single prompt for large set of variables

조회 수: 1 (최근 30일)
Sreenidhi Yeturi
Sreenidhi Yeturi 2021년 2월 25일
댓글: Sreenidhi Yeturi 2021년 2월 26일
Hi I have huge set of variables that require an input from the user I would like to prompt them for all of them at once. I cannot figure out how to use inputdlg() from the documentation. I'm currently using,
a = input('prompt')
b = input('prompt')
c = input('prompt')
d = input('prompt')
I want to find a better way to do this. Can someone help?
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 2월 25일
The only trick for inputdlg() is that it returns a cell array of character vectors and you have to convert the character vectors to numeric if appropriate.
Stephen23
Stephen23 2021년 2월 26일
You can use str2double.

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

답변 (1개)

Steven Lord
Steven Lord 2021년 2월 26일
How huge is the "huge set of variables"? If your function requires the user to enter hundreds or thousands of values, I would advise you not to require them to use input. Write a function that accepts data passed as input arguments. If you really want to allow your users to type the inputs in manually you can then write a script that calls input and passes that data into the function as input arguments. Users that already have the data in a form your function can accept can bypass the script and directly call the function.
  댓글 수: 1
Sreenidhi Yeturi
Sreenidhi Yeturi 2021년 2월 26일
This is the method I came up with. Thanks

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by