Good morning I want to create a Sfunction Matlab level 2 that will use as input and output some variable of classes Simulink.IntEnumType. Each class Simulink.IntEnumType. is created by a .m file like the folowing :
classdef Valeur_State < Simulink.IntEnumType
enumeration
Valeur1 (0)
Valeur2 (1110)
Valeur3 (1120)
Valeur4 (1130)
Valeur5 (1140)
Valeur6 (1150)
Valeur7 (1160)
end
end
In the matlab level 2 S function I can define an input port that will accept the variable of my class Simulink.IntEnumType using the value -1 (inherited) for the «DatatypeID »
block.InputPort(3).DatatypeID = -1; % -1 for inherited block.InputPort(3).Complexity = 'Real';
I have checked that the Simulink.IntEnumType variable is available for the Sfunction code.
But for an output port, the documentation writes that the « DatatypeID » must be defined explicitely. My problem is that I don’t know how to find the « DatatypeID » of my class « Valeur_State » < Simulink.IntEnumType
I am looking for this information since a week without succes.
On the forum i have find the proposal of the following code : It is possible to register custom fixed-point data type in the Level-2 MATLAB file S-Function as follows:
sSigned = 1;
wordLength = 16;
fracSlope = 1;
fixedExp = -9;
bias = 0;
obeyDataTypeOverride = false;
dtID = block.RegisterDataTypeFxpFSlopeFixExpBias ...
(isSigned, wordLength, fracSlope, fixedExp, ias, obeyDataTypeOverride);
block.InputPort(1).DatatypeID = dtID;
but I don’t reach to use it and I do not understand how the function could find the DatatypeID of a class without sending the name of this classe to the function !
please help !