MATLAB: How to determine the port data type of a masked subsystem in Simulink 7.5 (R2010a)

simulink

I would like to programmatically determine the port data type of a masked subsystem.

Best Answer

This can be done by querying the "CompiledPortDataTypes" block parameter after compiling the model. To see how you can do this, follow these steps:
1. Download the attached model "example.mdl".
2. Compile the model with the following command:
>> example([],[],[],'compile')
3. Query the "CompiledPortDataTypes" parameter of the subsystem block:
>> get_param('example/Subsystem','CompiledPortDataTypes')
This returns the port data types in cell arrays of strings, stored in the returned structure's "inport" and "outport" fields.
4. Terminate compilation:
>> example([],[],[],'term')