MATLAB: How to output all the Simulink model signals’ Output data type

MATLABsimulink

Hi guys, My current project is to findout all the signals' output data type(int16, int32, single, double..). How can I do this? And can i output these information into .CSV file? Thank a lot~

Best Answer

You can use the CompiledPortDataType property of block ports to get the port datatype.
outportBlks = find_system('modelname', 'BlockType', 'Outport');
outportDTs = cell(numel(outportBlks), 1);
modelname([],[],[],'compile')
for i = 1:numel(outportBlks)
outportBlk = outportBlks{i};
q=get_param(outportBlk,'PortHandles');
outportDTs{i} = get_param(q.Inport,'CompiledPortDataType');
end
modelname([],[],[],'term');
xlswrite('csvlist.dat',outportDTs);
I used xlswrite because it is the easiest way I could think of to write cell arrays out to a file (although it doesn't separate the strings will commas). You can of course choose one of the several techniques in MATLAB to write the variable outportDTs to a file.