Getting values out of uicontrol edit

38 ビュー (過去 30 日間)
Kai Walter
Kai Walter 2020 年 9 月 17 日
回答済み: Prabhanjan Mentla 2020 年 9 月 25 日
Hi all,
i wanted to make my inputdlg box prettier and easier to work with. Therefore i used uicontrols edits and buttons and i managed to create the design i'm happy with. But how do i get the values from the edit boxes. All don't get how the Callback functions work. I need help!
Here is the code for clearity:
function yourDlg()
input = struct;
d = dialog('Position', [800, 400, 200, 450]);
uicontrol(d,'Style','text',...
'String','General Parameters',...
'Position',[25 400 150 30],...
'FontWeight','bold');
uicontrol(d,'Style','text',...
'String','Peak',...
'Position',[25 375 150 30]);
input.peak = uicontrol(d,'Style','edit',...
'String','0002',...
'Position',[25 350 150 30],...
'Callback','DeleteFcn');
uicontrol(d,'Style','text',...
'String','angle to surface [°]',...
'Position',[25 275 150 30]);
input.angle = uicontrol(d,'Style','edit',...
'String','0',...
'Position',[25 250 150 30]);
uicontrol(d,'Style','text',...
'String','Data set',...
'Position',[25 175 150 30]);
input.omega = uicontrol(d,'Style','radiobutton',...
'String','Omega',...
'Position',[50 150 70 30],...
'HandleVisibility','off');
input.RSM = uicontrol(d,'Style','radiobutton',...
'String','RSM',...
'Position',[120 150 70 30],...
'HandleVisibility','off');
uicontrol(d,'Style','text',...
'String','Radiation wavelength [angstr]',...
'Position',[25 75 150 30]);
input.lambda = uicontrol(d,'Style','edit',...
'String','1.54056',...
'Position',[25 50 150 30]);
uicontrol(d,...
'Position',[62 10 75 30],...
'String','Close',...
'Callback','delete(gcf)');
end

採用された回答

Prabhanjan Mentla
Prabhanjan Mentla 2020 年 9 月 25 日
Hi,
Callbacks and sharing data among callbacks are necessary in order to get the values from the dialog box.
To fetch the data from UI control dialog box, you may refer something like this.
This following link helps better in structuring the uicontrol dialog box.
Hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by