Documentation Center

  • Trial Software
  • Product Updates

ssRegisterDataType

Register a custom data type

Syntax

DTypeId ssRegisterDataType(SimStruct *S, char *name)

Arguments

S

SimStruct representing an S-Function block.

name

Name of the custom data type.

Returns

The DTypeId associated with the registered data type. Otherwise, reports an error and returns INVALID_DTYPE_ID.

Description

Register a custom data type. Each data type must be a valid MATLAB® identifier. That is, the first character is an alpha and all subsequent characters are alphanumeric or "_". The name length must be less than 32. Data types must be registered in mdlInitializeSizes.

If the registration is successful, the function returns the DataTypeId associated with the registered data type; otherwise, it reports an error and returns INVALID_DTYPE_ID.

After registering the data type, you must specify its size, using ssSetDataTypeSize.

The Simulink® Coder™ product does not support S-functions that contain custom data types. Attempting to generate code for a model that contains this macro results in an error.

    Note   You can call this function to get the data type ID associated with a registered data type. For a list of built-in values for the data type ID, see ssGetInputPortDataType.

Languages

C, C++

Example

The following example registers a custom data type named Color.

DTypeId id = ssRegisterDataType(S, "Color");
if(id == INVALID_DTYPE_ID) return;

See Custom Data Types for a more detailed example showing how to use this function.

Was this topic helpful?