Current simulation time in MATLAB System block
t = getCurrentTime(obj)
If the MATLAB System block is operating in continuous sample time,
getCurrentTime may return non-monotonic times due to solver operation.
obj— System object
System object included in a MATLAB System block that you want to query.
t— Current simulation time
The current simulation time of the MATLAB System block that contains the System object.
This example of
stepImpl returns a count value
y and the current
ct. The simulation time is obtained by calling
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.