Add Value to GUI
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi! I take an answer 3 minutes ago. With the answer i can take values for my array Phone. Now i want to add this script to GUI. in the gui there is just one push button it is goin to be "add phone number". so How i can add this script to gui ?
n = 2
for ii = 1:n
Phone(ii).name = input('Enter the name: ', 's');
Phone(ii).number = input('Enter the phone number: ','s');
Phone(ii).address = input('Enter the address: ','s');
end
0 Commenti
Risposta accettata
Image Analyst
il 25 Mag 2012
n = 2;
dlg_title = 'Input for personal data';
num_lines = 1;
for k = 1:n
prompt1 = sprintf('Enter name #%d', k);
prompt2 = sprintf('Enter phone number #%d', k);
prompt3 = sprintf('Enter address #%d', k);
prompt = {prompt1, prompt2, prompt3};
answer = inputdlg(prompt,dlg_title,num_lines);
Phone(k).name = answer{1};
Phone(k).number = answer{2};
Phone(k).address = answer{3};
end
0 Commenti
Più risposte (4)
Matt Kindig
il 24 Mag 2012
To clarify, you are trying to make a GUI? Are you going to replace the calls to 'input' (which gets information from the command prompt) with text fields in the GUI (where you can type in the relevant information directly? If so, you should start with GUIDE, which will help you layout the GUI. There are a few examples in the startup for GUIDE to do things similar to your task.
At the command prompt, simply type
guide
3 Commenti
Walter Roberson
il 24 Mag 2012
vals = inputdlg('Phone book', 'name', 'number', 'address');
Phone(ii).name = vals{1};
...
Özgür Karagülle
il 24 Mag 2012
1 Commento
Walter Roberson
il 24 Mag 2012
n = 2
for ii = 1:n
vals = inputdlg('Phone book', 'name', 'number', 'address');
Phone(ii).name = vals{1};
Phone(ii).number = vals{2};
Phone(ii).address = vals{3};
end
Özgür Karagülle
il 24 Mag 2012
3 Commenti
Oleg Komarov
il 24 Mag 2012
@Özgür: please do not create additional answer but use comments or edit the original post.
I would suggest to avoid the GUI if you are new to MATLAB and interact with the user through the command line.
Özgür Karagülle
il 24 Mag 2012
4 Commenti
Image Analyst
il 25 Mag 2012
That's not the right way to use inputdlg() - see the help for the correct way.
Vedere anche
Categorie
Scopri di più su MATLAB Mobile in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!