Problem to output value from custom GUI with radiobuttons
Show older comments
Hi everyone,
I am new to creating GUI's. I have a very specific GUI I need for my thesis, that I can only create "programmatically". I want one option from two sets of radio buttons to be selected, and have that choice output as a cell array in my main script. The options are the names of metal alloys.
More specifically, I need the cell array alloy containing a name like 'FeSi' or 'CuSn' to be called in my main code like this:
alloy = Options_AmorphousAlloy3()
What I have is very basic, but I need someone to help me understand how I can output set(handles.Alloy,'Value'). I have done lots of reading, but I think I just need someone to help me understand how this goes together...
So far I have my callback functions, an output and an input function. The error I am getting "Unrecognized function or variable 'set'" (see image below).
Thank you so much if anyone has the time to help!

function varargout = Options_AmorphousAlloy3()
handles.FigureH = figure;
hp1 = uipanel('Title','Crystalline Alloys','FontSize',12,...
'Units', 'normalized','Position',[.08 .2 .4 .7]);
hp2 = uipanel('Title','Amorphous Alloys','FontSize',12,...
'Units', 'normalized','Position',[.52 .2 .4 .7]);
Pushbutton1 = uicontrol(gcf,'Style', 'push', 'String', 'Continue', ...
'Units', 'normalized', 'Position', [0.4 0.03 0.1 0.1], ...
'CallBack', @Pushbutton1_Callback);
Pushbutton2 = uicontrol(gcf,'Style', 'push', 'String', 'Close', ...
'Units', 'normalized', 'Position', [0.5 0.03 0.1 0.1], ...
'CallBack', @Pushbutton2_Callback);
handles.radio(1) = uicontrol('Parent', hp1, ...
'Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'normalized', ...
'Position', [0.2, 0.2, 0.5, 0.1], ...
'String', 'FeSi', ...
'Value', 1);
handles.radio(2) = uicontrol('Parent', hp1, ...
'Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'normalized', ...
'Position', [0.2, 0.4, 0.5, 0.1], ...
'String', 'CuSn', ...
'Value', 0);
handles.radio(3) = uicontrol('Parent', hp1, ...
'Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'normalized', ...
'Position', [0.2, 0.6, 0.5, 0.1], ...
'String', 'AlCu', ...
'Value', 0);
handles.radio(4) = uicontrol('Parent', hp2, ...
'Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'normalized', ...
'Position', [0.2, 0.26667, 0.5, 0.1], ...
'String', 'FeBSiP', ...
'Value', 0);
handles.radio(5) = uicontrol('Parent', hp2, ...
'Style', 'radiobutton', ...
'Callback', @myRadio, ...
'Units', 'normalized', ...
'Position', [0.2, 0.5333333, 0.5, 0.1], ...
'String', 'FeCoBSiNb', ...
'Value', 0);
...
guidata(handles.FigureH, handles);
function Options_AmorphousAlloy3_OpeningFcn(hObject, eventdata, handles, varargin)
set(handles.Alloy, 'Value', {'zero'});
uiwait(handles.Options);
function varargout = Options_AmorphousAlloy3_OutputFcn(hObject, eventdata, handles)
varargout{1} = get(handles.Alloy, 'Value');
function myRadio(RadioH, EventData)
handles = guidata(RadioH);
otherRadio = handles.radio(handles.radio ~= RadioH);
set(otherRadio, 'Value', 0);
for k = 1:length(handles.radio)
if (get(handles.radio(k),'Value') == get(handles.radio(k),'Max'))
idx = get(handles.radio(k),'String');
set(handles.Alloy,'Value') = {idx};
break
end
guidata(handles.FigureH, handles)
end
function Pushbutton1_Callback(ObjectH, EventData)
uiresume(gcbf)
close(gcf)
function Pushbutton2_Callback(ObjectH, EventData)
close(gcf)
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!