step

Runs one processing step of a System object.

Category: Programming > Classes

Syntax

y = step(obj, x)

Processes the input x and returns the output of one step. Equivalent to y = obj(x).

[y1, y2] = step(obj, x1, x2)

Passes several inputs and collects several outputs, as the class's stepImpl defines.

Description

A System object is a handle class derived from matlab.System whose work is done by stepImpl. The first call to step runs setupImpl, locks the object and then runs stepImpl; later calls run stepImpl only, so the object can keep state between calls, such as the running total in a counter.

step can be written as a function call on the object itself: y = obj(x) does the same. To start over without discarding the object, call reset; to unlock it, call release.

Input arguments

obj
A System object.
x, x1, x2
Input arguments, as many as stepImpl declares.

Output arguments

y, y1, y2
Outputs returned by stepImpl.

Example

Stateful processing

writelines([ ...
  "classdef Counter < matlab.System", ...
  "  properties", "    Total = 0", "  end", ...
  "  methods (Access = protected)", ...
  "    function setupImpl(obj)", "      obj.Total = 100;", "    end", ...
  "    function y = stepImpl(obj, u)", "      obj.Total = obj.Total + u;", "      y = obj.Total;", "    end", ...
  "    function releaseImpl(obj)", "      disp('released')", "    end", ...
  "  end", "end"], 'Counter.m');
c = Counter;
y1 = step(c, 5)
y2 = c(7)
Output
y1 = 105
y2 = 112

The first step runs setupImpl (total 100) and then adds 5; the second call, written as c(7), adds 7.

See also

setup release reset isLocked clone