How do I query the data type of every input and output port in a Simulink model?

16 views (last 30 days)
When I select Port data types from the Format menu of a Simulink model, I can see the data type of every input and output port in this model. I would like to query these data types from command line or a script, and I also want to be able to do this using a generic model name such as gcs.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Jun 2010
Note that in order to query the data type, you need to compile the model first. Try the following example:
vdp
% open the model
vdp([],[],[],'compile');
% compile the model
h = get_param('vdp/Mu','Porthandles');
% get the port handles
get_param(h.Outport,'CompiledPortDataType')
% get the output port data type
vdp([],[],[],'term')
% terminate the compilation
For a generic model name such as 'gcs', consider using the EVAL function. Here is an example:
vdp
eval([gcs,'([],[],[],''compile'');'])
h = get_param('vdp/Mu','Porthandles');
get_param(h.Outport,'CompiledPortDataType')
eval([gcs,'([],[],[],''term'')'])

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!