update - Update state of a System object based on inputs - MATLAB (original) (raw)

Main Content

Update state of a System object based on inputs

Syntax

Description

update([obj](#mw%5F4764c6e1-dfc1-4ce0-a285-0facaac30e64),[input1, input2, ..., inputN](#mw%5F13b017a5-5a09-46da-b350-a0842498eeea)) updates the states of a System objectâ„¢ based on the algorithm specified in the updateImpl method.

example

Examples

collapse all

Call update to update the states of a System object.

Consider a System object object defined as,

classdef UnitDelayNondirect < matlab.System % UnitDelayNondirect Delay input by one time step

properties(DiscreteState) State end

methods(Access = protected)
    function resetImpl(obj)
        obj.State = 0; % Initialize states
    end
    function y = outputImpl(obj, ~)
        y = obj.State; % Output current state

    end
    function updateImpl(obj,u)
        obj.State = u; % Update state with input
    end
end

end

Create an instance of the System object and provide it with an input.

a = UnitDelayNondirect(); out = a(1);

Call update to update the states of the System object with new inputs.

Input Arguments

collapse all

System object handle used to access properties, states, and methods specific to the object.

Inputs to the System object. The order of inputs must match the order of inputs defined in the updateImpl method.

Version History

Introduced in R2012a