Main Content

ssGetElapseTime

Get the value of elapse time counter associated with the S-function

Since R2023b

Syntax

void ssGetElapseTime(SimStruct *S, double *elapseTime)

Arguments

S

SimStruct that represents an S-Function block.

elapseTime

The location of variable with double data type where elapse time value is to be stored

Description

Use to get the value of elapse time of the counter associated with the S-function. ssGetElapseTime writes the value of elapse time counter to the location specified by the pointer elapseTime.

Languages

C, C++

Examples

The following code snippet for an S-function returns the elapse time value as the output of the S-function block.

static void mdlInitializeSampleTimes(SimStruct *S)
{
    ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
    ssSetOffsetTime(S, 0, 0.0);
    ssSetModelReferenceSampleTimeDefaultInheritance(S); 
    ssSetNeedElapseTime(S, 1);
}

static void mdlOutputs(SimStruct *S, int_T tid)
{
    void  *y = ssGetOutputPortSignal(S,0);
    
    ssGetElapseTime(S, y);       
}

Version History

Introduced in R2023b