user define dialog box or GUI

7 vues (au cours des 30 derniers jours)
Idan Cohen
Idan Cohen le 7 Mai 2020
Modifié(e) : Idan Cohen le 8 Mai 2020
Hi all,
I wrote a function in Matlab that asks input from the user. I used this script and similar four times:
prompt = {'Enter the Value of a on SIDE 2','Enter the Value of b on SIDE 2','Enter the Value of c on SIDE 2'};
dlgtitle = 'Calculate ZReal - ZReal=a(Z[V])^2+b*(Z[V])+c';
definput = {'6.1101e-9','-2.3062e-04','17.372'};
opts.Interpreter = 'tex';
temp = inputdlg(prompt,dlgtitle,[1 140],definput,opts);
a=str2num(temp{1});
b=str2num(temp{2});
c=str2num(temp{3});
This dialog box do the job, but I'm looking for something easier and nicer. I thought about using GUI, but I don't know how to start the GUI from a function, get the data and close the GUI.
I will appreciate your help.
Thanks.

Réponse acceptée

Rik
Rik le 7 Mai 2020
Easier and nicer might be mutually exclusive.
If you want tips and examples about GUI design, I encourage you to check out this thread.
  3 commentaires
Rik
Rik le 7 Mai 2020
  1. Look through the documentation page with the uicontrol properties. There are a lot of them, and I know at least the size can be changed, I would have to look up Color.
  2. No, but you can set the String property when you create the element to anything you like, which I would argue is the same effect as a default.
  3. With some of the uicontrol styles you can set the Max property to something higher than 1 and set a cell array as the String property to have multiple lines of text. You can even set Max to inf. Note that for an edit field this will stop the callback from working as intended.
Glad to be of help.
If my answer solved your issue, please consider marking it as accepted answer.
Idan Cohen
Idan Cohen le 8 Mai 2020
Modifié(e) : Idan Cohen le 8 Mai 2020
The way to do that, if someone will read, for question 1 (2 and 3, still working to find the answer)
You specify one of the uicontrol as variable:
test==uicontrol('Style','Text',...
'Units','Normalized',...
'Position',[0.05 .55 .1 .1],...
'String','Enter a',...
'FontSize',[12],...
'CallBack','uiresume(gcbf)');
for color - set(a1_text,'ForegroundColor','blue');
for bold - set(Side_1,'FontWeight','bold');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by