Clear Filters
Clear Filters

How to find the « DataType ID » of a class Simulink.IntEnumType

3 views (last 30 days)
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:
% Register fixed point datatype to obtain datatype id i
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 !
  1 Comment
daniel Monterrain
daniel Monterrain on 6 Mar 2019
My question (How to find DATA TYPE ID of a simulink ENUM class) is now a bloking point for my project. I have founded a solution not to use output of my matlab level 2 S function for output of class Simulink.IntEnumType, using blocks out of the S function and writing in this block from the S function using a set_param. it is oK (but not efficient?)
Now i want to compile my model to build a library and afer a standalone application. But the Set_param command cannot be used in this case!
How can i do ?
please help !

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!