How can I choose the Inputs in the input dialogue box and enter value of the selected ones ?

7 ビュー (過去 30 日間)
I want a dialogue box which asks users to choose the Inputs(Variables of a function) they want to give and then enter their values as input.
As an example,
Please choose atleast 2 Variables from below
u
R
H
t
theta
th
ux
uy
If I choose u and theta then in the next dialogue box (or in the same dialogue box) I can enter the value of variables I've chosen. I also want to display some text over that box for instructions like units of variables etc.
list={'ux','uy','t','u','theta','x','y','r','R','H','th'}
[indx,tf] = listdlg('ListString',list,"SelectionMode",'multiple')
%list1 is column vector that contains text I want to display in the upcoming dialogue box
list1=["Enter a value of ux in m/s";"Enter a value of uy in m/s";"Enter a value of t in s";"Enter a value of u in m/s";"Enter a value of \theta (in degrees)";"Enter a value of x in m";"Enter a value of y in m";"Enter a value of r in m";"Enter a value of R in m";"Enter a value of H in m";"Enter a value of th in s"];
% PROMPT IS NOT WORKING PROPERLY !!!
prompt = {'',strjoin(arrayfun(@(x) num2str(x),list1(indx),'UniformOutput',false),''',''')};
dlgtitle = 'Input Value';
% HOW TO CHANGE DEFINPUT VALUES ACCORDING TO THE CHOSEN INPUT VARIABLES?
definput = {'0','0','0','0','0','0','0','0','0','0','0'};
opts.Interpreter = 'tex';
answer = inputdlg(prompt,dlgtitle,[1 40],definput,opts);
I hope my problem is clear and understandable. Please feel free to ask any questions.
How can I resolve this issue ?

採用された回答

Ajit Kasturi
Ajit Kasturi 2020 年 6 月 19 日
I have made some changes in your code and I think it is working fine now. I have just added items to prompt and definput dynamically based on the indx vector which captures the indices of the inputs you have picked.
list={'ux','uy','t','u','theta','x','y','r','R','H','th'}
list0=['Enter a value of ux in m/s',"Enter a value of uy in m/s","Enter a value of t in s","Enter a value of u in m/s","Enter a value of \theta (in degrees)","Enter a value of x in m","Enter a value of y in m","Enter a value of r in m","Enter a value of R in m","Enter a value of H in m","Enter a value of th in s"]
list1=['1','2','3','4','5','6','7','8','9','0','1']
[indx,tf] = listdlg('ListString',list,"SelectionMode",'multiple')
prompt=[]
dlgtitle = 'Input Value';
definput = {}
for i=1:length(indx)
prompt=[prompt,list0(indx(i))];
definput=[definput,list1(indx(i))]
end
opts.Interpreter = 'tex';
answer = inputdlg(prompt,dlgtitle,[1 40],definput,opts);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWord games についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by