Radio Buttons Matlab GUI

I had an existing GUI, and tried to add another panel of Radio Buttons. I did this using guide. I then copied and pasted the existing working code from another uipanel, changing the suitable variables, assuming this would work (obviously changing the tags and strings for the radio button) but nothing was happening, and they weren’t working as I wanted them to.

A simple test for it working is under your copied and suitably changed function uipanel1_SelectionChangeFcn(hObject, eventdata, handles) add fprintf(‘does this work?’). If it works, every time you change your selection, that should be printed into your command history.

Mine didn’t work and I couldn’t figure out why, or find on the internet the reason why this should be. I was comparing properties of the buttons and panels for ages using the ‘property inspector’.

I found the solution in the end to be going through the motions of creating a new function in the guide, by right clicking the panel, view callbacks, then SelectionChangeFcn. This then takes you to the code you’ve had all along, but I assume it adds a reference for it in the hidden back end files (such as guidefunc.m) that is necessary.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s