I define a Simulink.NumericType object 'MY_TYPE' as follows:
>> MY_TYPE = Simulink.NumericType;
>> MY_TYPE.DataTypeMode = 'Fixed-point: slope and bias scaling';
>> MY_TYPE.Signedness = 'Unsigned';
>> MY_TYPE.WordLength = 32;
>> MY_TYPE.Slope = 1000;
>> MY_TYPE.Bias = 0;
>> MY_TYPE.IsAlias = 1;
>> MY_TYPE.DataScope = 'Auto';
>> MY_TYPE.HeaderFile = 'Rte_Type.h';
and then try to cast an input variable IN to such type in a Stateflow chart:
OUT = cast(IN,'MY_TYPE');
However, I encounter the following error:
'MY_TYPE' is not supported as an operand to cast
When instead I use a Data Type Conversion block in Simulink, the conversion to my custom type is correctly executed.
Is it possible to perform casting for a non built-in data type in Stateflow? Alternatively, how can I implement in Stateflow the corresponding behaviour of the Data Type Conversion block in Simulink?
Best Answer