How to change the size of Radio-button icon?

9 visualizaciones (últimos 30 días)
abb Shp
abb Shp el 7 de Nov. de 2020
Editada: Walter Roberson el 9 de Jun. de 2025
Hi, i want to change the size of radio button icon in GUI using uicontrol command;
Radiobutton = uicontrol('Style','radiobutton','Position',[20,10,width,height]);
i use different values for width and height but it doesnt chane the size of radio button icon in GUI,
appreciate any help

Respuestas (1)

Darshak
Darshak el 9 de Jun. de 2025
Hello @abb Shp,
I’ve encountered the same situation — when using the “uicontrol” function to create a radio button, changing the “Position” values affects the overall control area but doesn’t resize the actual circular icon of the radio button.
This happens because the icon's size is controlled by the operating system, so it doesn't change even if you resize the button. If you want more control over how it looks and scales, there's a simple workaround I found that can help.
• You can simulate a radio button using a “togglebutton” with a custom icon.
• This involves creating two image assets: one for the selected state and one for the unselected state.
• You then load these images in MATLAB and update them based on the button’s value.
Here’s a general structure for how you might set that up:
unselectedIcon = imread('unselected.png');
selectedIcon = imread('selected.png');
hToggle = uicontrol('Style', 'togglebutton', ...
'CData', unselectedIcon, ...
'Position', [20, 10, 100, 100], ...
'Callback', @toggleCallback);
function toggleCallback(hObject, ~)
if get(hObject, 'Value')
set(hObject, 'CData', selectedIcon);
else
set(hObject, 'CData', unselectedIcon);
end
end
The “CData” property lets you place an image on the toggle button. You can scale the image and the button together to get the appearance you’re aiming for. It’s also quite flexible — you can design your own icons and apply any visual style you like.
Here are the official documentation links if you'd like to explore further:
• uicontrol documentation:
• CData property reference:

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by