Info

This question is closed. Reopen it to edit or answer.

Exporting choices from radiobutton to GUI

1 view (last 30 days)
Eric Goh
Eric Goh on 12 Oct 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, does anyone how do you export a choice from a radiobutton in a button group into an excel file in Guide?
the button group has 5 radio buttons and when 1 of the button is selected then the user will click done and that choice is exported into an excel file.

Answers (1)

Geoff Hayes
Geoff Hayes on 12 Oct 2015
Eric - you can do all of this work in the callback for your Done button. Something like the following will do
function pushbutton1_Callback(hObject, eventdata, handles)
% get the selected radio button
hSelectedRadioBtn = get(handles.uipanel1,'SelectedObject');
% write whatever you need to the Excel file
xlswrite(....);
In the above, the uipanel1 is the assumed name/tag for the radio button group, and hSelectedRadioBtn is the handle to the selected radio button. You don't say what you want to write out to file...perhaps the text string corresponding to this button (?). If so, you can grab the option string through
radioBtnStr = get(hSelectedRadioBtn,'String');
You can then use xlswrite to write the option string to file (assuming that you already have the file name and cell within the spreadsheet of where to write the option to).

Community Treasure Hunt

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

Start Hunting!