Main Content

update

Update state of a System object based on inputs

    Description

    example

    update(obj,input1, input2, ..., inputN) updates the states of a System object™ based on the algorithm specified in the updateImpl method.

    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.

    update(a,2);

    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