Register a custom data type from a Simulink.AliasType, Simulink.NumericType, or Simulink.Bus object.


void ssRegisterTypeFromNamedObject(SimStruct *S, char *name, int* id)



SimStruct representing an S-Function block.


Name of the Simulink® object to assign to the custom data type.


An integer whose value is the numeric data type identifier after the call to ssRegisterTypeFromNamedObject.


Use in mdlInitializeSizes, to register a custom data type from a Simulink.AliasType, Simulink.NumericType, or Simulink.Bus object named name.

If the registration was successful, you can declare S-function parameters, DWork vectors, or input and output ports to be of this data type, using the corresponding numeric data type identifier id. If the registration was not successful, id is set to INVALID_DTYPE_ID.

    Note   You may not register a custom data type from a Simulink.NumericType object with unspecified scaling.

Bus S-function Usage Guidelines

Use this S-function in simulations. You cannot use this S-function for code generation.

This S-function does not support bus elements that have any of the following characteristics:

  • Variable dimensions

  • Frames

  • Enumerated (enum) data types

To use this S-function and other bus-related S-functions, before you run the simulation, execute the following MATLAB® command:

set_param(block_handle, 'EnableBusSupport', 'on')

To automate setting the EnableBusSupport parameter, use one of the following approaches:

  • Add the command to the model initialization callback.

  • Mask the S-Function block and add the command to the mask initialization callback


C, C++


The following example registers a custom data type from the Simulink.Numeric type named mydouble. It then specifies that a DWork vector and the first output port be of this data type.

int dtype;
char *name = "mydouble";
ssRegisterTypeFromNamedObject(S, name, &dtype);
ssSetDWorkDataType(S, 0, dtype);
ssSetOutputPortDataType(S, 0, dtype);
Was this topic helpful?