matlab.system.getCurrentTime - Current simulation time in MATLAB System block - MATLAB (original) (raw)

Main Content

Current simulation time in MATLAB System block

Syntax

time = getCurrentTime(obj)

Description

[time](#d126e592990) = getCurrentTime([obj](#d126e592964)) returns the current simulation time in the MATLAB System block. Call this method in the stepImpl method of your System objectâ„¢.

Dependencies

If the MATLAB System block is operating in continuous sample time,getCurrentTime may return non-monotonic times due to solver operation.

Input Arguments

expand all

System object included in a MATLAB System block that you want to query.

Output Arguments

expand all

The current simulation time of the MATLAB System block that contains the System object.

Examples

expand all

This example of stepImpl returns a count valuey and the current simulation timect. The simulation time is obtained by callinggetCurrentTime.

function [y,ct] = stepImpl(obj,u)
    y = obj.Count + u;
    obj.Count = y;
    ct = getCurrentTime(obj);
end

For a complete class definition, see Specify Sample Time for MATLAB System Block System Objects.

Version History

Introduced in R2017b