MATLAB: Is there an example for writing a C-MEX S-function that inherits a fixed-point aliased data type from an object in the base workspace

aliastypemptnumerictypesfunsimulink

I am trying to write a C-MEX S-function that calls some legacy code and I need to pass several arrays to the function with a fixed point or void type. I can get the types of the s-function ports set to built-in types such as "int16" or "uint16" but I can't set them to a fixed-point type.
I need to use a fixed point alias type for my parameters. The type will be determined by a parameter object in the base workspace. The object is either from the MPT class (mpt.Parameter) or some derived class. The parameters need to be passed to the legacy function being called.

Best Answer

Attached is an example of an s-function that will inherit a fixed-point data type from an object in the base workspace.
1. Load the MAT file workspace.mat. It contains three objects, a Simulink.NumericType object which represents the fixed-point data type, a Simulink.AliasType object which represents an alias to the Simulink.NumericType object, and finally a Simulink.Parameter object whose data type is defined by the Simulink.AliasType object.
2. Compile the S-function using MEX.
3. Load the model provided and update the diagram to see that the input signal to the s-function acquires the alias (fixed-point) type.