MATLAB: How to get the port types and dimensions for a block

rtw port dimension typesimulinksimulink coder

We are generating code using RTW via a script. I am trying to collect the port dimensions and data types. Argument names would be great too, but not required.
I am currently able to get the port names

Best Answer

Sometimes it is hard to find help in the document. Many times I just poke around and make an educated guess. I made a simple model and ran the code below. It seems to be able to get the dimension and data types. Hope this will help.
clc;
acModelName=bdroot;
lcInportHandles = find_system(acModelName,'FindAll','On','SearchDepth',1,'BlockType','Inport');
for i=1:length(lcInportHandles)
lcInputDimensions = get_param(lcInportHandles(i),'CompiledPortDimensions');
lcInputDimensions=lcInputDimensions.Outport
lcInputDataTypes = get_param(lcInportHandles(i),'CompiledPortDataTypes');
lcInputDataTypes = lcInputDataTypes.Outport
end
The output looks like this:
lcInputDimensions =
1 2
lcInputDataTypes =
'single'
lcInputDimensions =
1 1
lcInputDataTypes =
'int8'