Main Content

clone

Copy online state estimation object

Description

example

obj_clone = clone(obj) creates a copy of the online state estimation object obj with the same property values.

If you want to copy an existing object and then modify properties of the copied object, use the clone command. Do not create additional objects using syntax obj2 = obj. Any changes made to the properties of the new object created in this way (obj2) also change the properties of the original object (obj).

Examples

collapse all

Create an extended Kalman filter object for a van der Pol oscillator with two states and one output. To create the object, use the previously written and saved state transition and measurement functions, vdpStateFcn.m and vdpMeasurementFcn.m. Specify the initial state values for the two states as [2;0].

obj = extendedKalmanFilter(@vdpStateFcn,@vdpMeasurementFcn,[2;0])
obj = 
  extendedKalmanFilter with properties:

        HasAdditiveProcessNoise: 1
             StateTransitionFcn: @vdpStateFcn
    HasAdditiveMeasurementNoise: 1
                 MeasurementFcn: @vdpMeasurementFcn
     StateTransitionJacobianFcn: []
         MeasurementJacobianFcn: []
                          State: [2x1 double]
                StateCovariance: [2x2 double]
                   ProcessNoise: [2x2 double]
               MeasurementNoise: 1
         HasMeasurementWrapping: 0

Use clone to generate an object with the same properties as the original object.

obj2 = clone(obj)
obj2 = 
  extendedKalmanFilter with properties:

        HasAdditiveProcessNoise: 1
             StateTransitionFcn: @vdpStateFcn
    HasAdditiveMeasurementNoise: 1
                 MeasurementFcn: @vdpMeasurementFcn
     StateTransitionJacobianFcn: []
         MeasurementJacobianFcn: []
                          State: [2x1 double]
                StateCovariance: [2x2 double]
                   ProcessNoise: [2x2 double]
               MeasurementNoise: 1
         HasMeasurementWrapping: 0

Modify the MeasurementNoise property of obj2.

obj2.MeasurementNoise = 2;

Verify that the MeasurementNoise property of original object obj remains unchanged and equals 1.

obj.MeasurementNoise
ans = 1

Input Arguments

collapse all

Object for online state estimation of a nonlinear system, created using one of the following commands:

Output Arguments

collapse all

Clone of online state estimation object obj, returned as an extendedKalmanFilter, unscentedKalmanFilter or particleFilter object with the same properties as obj.

Version History

Introduced in R2016b