How do I make a set of mutually exclusive radion buttons?

Hi all.
I am trying to make a GUI which essentially generates the ksdensity plot of the selected radiobutton from a list of displayed radiobuttons. But, when I select one of the radiobuttons, the previously selected does not get unselected. My code for generating the radiobuttons:
f = figure;
posFig = get(f,'Position');
hFig = posFig(4); % height of the figure
fields = fieldnames(ranked_rbc); %ranked_rbc is a structure variable
for k=1:1:6
rdbutton(k) = uicontrol('Style','radiobutton','String',fields{k}, ...%fields is a cell array that generates the radiobutton titles
'Value',0,'Position',[20 hFig - (20*(k-1)+50) 130 20], ...
'Callback',{@radioButtonCallback,k});
end
My code for the callback function:
function radioButtonCallback(source, data, index)
fprintf('Radion Button %s is %d\n',get(source,'String'),get(source,'Value'));
rbc_plot=load('training_rbc.mat');
infected_plot=load('training_infected.mat');
rbc_plot = rbc_plot.rbc_Selected;
infected_plot = infected_plot.infected_Selected;
fields = fieldnames(rbc_plot);
plot_ksdensity(double(rbc_plot.(get(source,'String'))));
hold on;
plot_ksdensity(double(infected_plot.(get(source,'String'))),'r');
xlabel(get(source,'String'));
ystr = strcat('probability density of',get(source,'String'));
ylabel(ystr);
legend('RBC Cells','Infected Cells');
hold off;
end
How do I make the radiobuttons mutually exclusive and where do I need to add the code for that? Thanks for the help.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 10 Aug 2015

Answered:

on 10 Aug 2015

Community Treasure Hunt

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

Start Hunting!