MATLAB: How to know if the data types defined in different ways are equivalent in Simulink 7.6 (R2010b)

simulink

I am wondering if there is any way to compare if a Fixed Point data type is equal to another data type that could be equivalent. For example:
fixdt(0,16,1,0), fixdt(1,16,0.125,0)
are actually equivalent to
uint16, fixdt(1,16,3)
respectively.
Sometimes, for example, we can found some ports which are defined as fixdt when actually it should be defined as uint (when this happens, Matlab changes the compiled data type automatically). We would like to capture those discrepancies in order to show a warning, but at the same time we would like to know exactly if the data types are equivalent.

Best Answer

From the block properties in the 'Common Block Properties' documentation, there are two properties that are helpful in this case. One is 'outDataTypeStr' which is decided by the specification in the 'Block Parameters' dialog, the other is 'CompiledPortDataTypes' which is the same as the 'Port Data Types' if you turned on the 'Port Data Types' display and updated the diagram. In the attached script, I have used these two properties in a few comparisons to achieve the desired functionality requested.
Note: for 'CompiledPortDataTypes' to work, the model need to be in 'Compiled Mode', and this is why I used the following codes in the script:
equivalent_datatypes([],[],[],'compile');
equivalent_datatypes([],[],[],'term');