Apply the plot to the selected axes
- Provide each of the 6 switches with a unique name or tag (see image below).
- Assign the same callback function to all 6 on-off switches.
- Within the switch-callback function, you can use the inputs to determine which switch was activated based on the uniqe name/tag. event.Source.Tag
- Add a private property to the app named "ActiveSwitch" (you can rename it).
- One of the switches should be on by default and others should be off. This can be done in design mode or from within DesignView or within the app's startup function. Copy the tag of the switch that's on to the ActiveSwitch property.
- When a switch is activated, the callback function will turn off the other 5 switches and will update the ActiveSwitch property with the switch's tag. This property will keep track of which swtich is active (see code below).
- When it's time to do the plotting, just use the tag stored in ActiveSwitch to determine which axes to use.
An example app is attched. It only contains 4 switches and shows how to achieve steps 1-6.
The callback function SwitchValChange is assigned to all switches:
function SwitchValChange(app, event)
value = event.Source.Value;
event.Source.Value = 'On';
app.ActiveSwitch = event.Source.Tag;
switchHandles = [app.Switch1, app.Switch2, app.Switch3, app.Switch4];
tags = get(switchHandles, 'Tag');
isActive = strcmpi(tags, event.Source.Tag);
set(switchHandles(~isActive), 'Value', 'Off')
How to assign tags to switches:
Enlarge the selected axes
I don't fully understand this part, "...displays the UIAxes at a defined position just a little larger than on the right side". Have you tried updating the axes position properties?