Getting values out of uicontrol edit

37 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by