How to use a Radio Button Group

5 views (last 30 days)
Timothy
Timothy on 24 Jun 2013
I have been trying to program a radio button group to display a set of gui components when one radio button is selected and a different set whne another radio buttonis selected. This GUI is a pop up window from another GUI. When the radio button is clicked the error attempt to reference field of non-structure array pops up. Heres my code
Build the Hfig that pops up when the product expectations tab is called
function h = ProductE(hObject, eventdata, h)
h.ProdE_fig = figure('Position', [95 459 300 250], 'MenuBar', 'None');
% Builds a Radio Button Set for the Panel h.buttonGroup = uibuttongroup('parent', h.ProdE_fig, 'Title',... 'Products Returned', 'Position', [0.55 0.352 0.4 0.35],... 'selectionchangefcn', @For_Inv_SelectionChangeFc);
h.ProdE_Radio1 = uicontrol('parent', h.buttonGroup, 'Style', 'radiobutton',... 'String', 'Forward', 'Units', 'normalized',... 'Value', 1, 'Position', [0.1 0.6 0.7 0.2], 'Tag', 'Forward');
h.ProdE_Radio2 = uicontrol('parent', h.buttonGroup, 'Style', 'radiobutton', ... 'String', 'Inverse', 'Units', 'normalized',... 'Position', [0.1 0.2 0.7 0.2], 'Tag', 'Inverse'); % h.buttonGroup('SelectionChangeFcn', {@For_Inv_SelectionChangeFcn}); %set(h.ProdE_Radio1, 'callback', {@For_Inv_SelectionChangeFcn}); set(h.ProdE_Radio2, 'callback', {@For_Inv_SelectionChangeFcn}); % guidata(hObject, h); end % function h = For_Inv_SelectionChangeFcn(hObect, eventdata, h) %Builds thhe Edit and Static Text Fields that coorespound with When Forward %is selected switch get(eventdata.NewValue, 'Tag') case 'Forward' bug 12 h.Forward_Edit1= uicontrol('parent', h.ProdE_fig, 'Style', 'edit', ... 'String', 'Enter a Number', [100 475 75 40]); h.Forward_Edit2= uicontrol('parent', h.ProdE_fig, 'Style', 'edit', ... 'String', 'Enter a Number', [50 160 75 40]); h.Forward_Edit3= uicontrol('parent', h.ProdE_fig, 'Style', 'edit', ... 'String', 'Enter a Number', [50 100 75 40]); % Build Static Text Boxes h.Forward_Static1 = uicontrol('parent', h.ProdE_fig, 'Style', 'text', ... 'String', '# Fractures', 'Position', [10 220 50 40]); h.Forward_Static2 = uicontrol('parent', h.ProdE_fig, 'Style', 'text', ... 'String', 'Fracture Spacing', 'Position', [10 160 50 40]); h.Forward_Static3 = uicontrol('parent', h.ProdE_fig, 'Style', 'text', ... 'String', 'Injection Rate', 'Position', [10 100 50 40]); case 'Inverse' bug 22
%%%TODO: MAKE A CALL BACK FOR THE RADIO BUTTON IT NEED TO have one
end
end
Does anyone have any ideas. Thanks a lot.

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!