Query sample time
sts = getSampleTime(obj)
returns the sample time
specification for the System
sts = getSampleTime(
obj when the System
object is included in a MATLAB System block. You can call
getSampleTime in the
stepImpl method to change the algorithm based on the sample time.
Before sample time has propagated throughout the MATLAB System block model,
getSampleTime returns the
getSampleTimeImpl sample time
specification. If your system object does not override
getSampleTimeImpl, the default
Inherited sample time specification is returned.
After sample time has propagated,
getSampleTime returns the sample time specification populated
with the actual MATLAB System block sample time type, sample time, and offset time.
obj— System object
System object included in a MATLAB System block that you want to query.
This example of
stepImpl returns a count value
y, the current
ct, and the sample time
st. The sample time is
obtained by calling
function [y,ct,st] = stepImpl(obj,u) y = obj.Count + u; obj.Count = y; ct = getCurrentTime(obj); sts = getSampleTime(obj); st = sts.SampleTime; end
For a complete class definition, see Specify Sample Time for MATLAB System Block System Objects.