Main Content

ssRegisterUnitFromExpr

Register unit from unit expression

Syntax

void ssRegisterUnitFromExpr(SimStruct *S, char *unitExpr, UnitId *id);

Arguments

S

SimStruct that represents an S-Function block.

unitExpr

Function pointer corresponding to the unit expression for the unit being registered.

id

An integer whose value is the numeric unit type identifier after the call to ssRegisterUnitFromExpr.

Description

Use this function in mdlInitializeSizes to register the unit. Use the returned unit ID to specify the unit of the input or output for the ssSetInputPortUnit and ssSetOutputPortUnit functions.

If the registration is successful, you can declare input and output ports to have this unit, using the corresponding unit id. If the registration is not successful, id is set to INVALID_UNIT_ID.

Languages

C, C++

Examples

UnitId id = INVALID_UNIT_ID; 
ssRegisterUnitFromExpr(S , "m/s" , &id); 
if (id == INVALID_UNIT_ID) return; 

ssSetInputPortUnit(S, portIdx, id); 
ssSetOutputPortUnit(S, portIdx, id);

Version History

Introduced in R2016b