MATLAB: Controlling manual switch through m-file

manual switch blockMATLABsimulinkswitch

there in a manual switch,which can be altered during run time.now if i want to alter the switch through m-file command.what to do?

Best Answer

It looks like this should work
set_param('path/to/block', 'sw', '0')
set_param('path/to/block', 'sw', '1')
I found the names of the block parameters using this command, and just picked the one that seemed likely:
>> get_param(gcb, 'DialogParameters') % select the block first with the mouse