Main Content

clone

Copy online state estimation object

Description

example

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

If you want to copy an existing object and then modify properties of the copied object, use theclonecommand. Do not create additional objects using syntaxmethoda = 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.mandvdpMeasurementFcn.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

Usecloneto 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

Modify theMeasurementNoiseproperty ofobj2.

obj2.MeasurementNoise = 2;

Verify that theMeasurementNoiseproperty of original objectobjremains 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 objectobj, returned as anextendedKalmanFilter,unscentedKalmanFilterorparticleFilterobject with the same properties asobj.

Introduced in R2016b