MATLAB: Automating Signal Storage Class in M script

How do I specify the storage class for a signal in m script? I would like to automate this process. For example, under signal properties–>RTW–>Storage Class….I would like to set the signal to Imported Extern.
Thanks in advance!

Best Answer

If you already have a Simulink.Signal object associated with the relevant signal line, then you can use code similar to what Titus suggested (just switch Simulink.Parameter with Simulink.Signal). But if you just want to operate directly on a named signal, and have the handle to the signal, you can set it using the "RTWStorageClass" property. For example, using a demo model called "busdemo":
open_system('busdemo');
ph = get_param('busdemo/Bus Creator', 'PortHandles');
set(ph.Outport, 'RTWStorageClass', 'ImportedExtern');
(The last line will error out if you do not have a signal name, in which case you may set that using the SET command for the SignalName property)