setMeasurementSizes
Description
setMeasurementSizes(
sets the expected sizes of the measurement and measurement noise to the values in the
filter
,measurementSize
,measurementNoiseSize
)measurementSize
and measurementNoiseSize
input
arguments. When working with variable-sized measurements, use this function before passing
measurements of new sizes to other object functions such as correct
and distance
.
Note
Only trackerGNN
and trackerJPDA
support
variable-sized measurement, but not for the trackingKF
filter.
Examples
Updating Measurement and Measurement Noise Size for Linear Kalman Filter
Create a linear Kalman filter that uses a 3D constant velocity motion model. Initialize the filter with a starting state vector indicating position and velocity.
KF = trackingKF(MotionModel="3D Constant Velocity" ... ,State=[100;0;0;0;0;0]); predict(KF,1)
Predict the state of the filter after 1 second and use the distance
function to lock the measurement model.
distance(KF,[100;0;0])
ans = 3.5360
Display the current measurement model, measurement noise, and state covariance matrix.
disp(KF.MeasurementModel)
1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0
disp(KF.MeasurementNoise)
1 0 0 0 1 0 0 0 1
disp(KF.StateCovariance);
2.2500 1.5000 0 0 0 0 1.5000 2.0000 0 0 0 0 0 0 2.2500 1.5000 0 0 0 0 1.5000 2.0000 0 0 0 0 0 0 2.2500 1.5000 0 0 0 0 1.5000 2.0000
To update the measurement and measurement noise sizes for the filter, use the setMeasurementSizes
function.
setMeasurementSizes(KF,2,2);
Update the measurement model of the Kalman filter to consider only the position in the x and z directions. Set the measurement noise to 3, which will scalar expand into a 2-by-2 matrix.
KF.MeasurementModel = [1 0 0 0 0 0; 0 0 1 0 0 0]; KF.MeasurementNoise = 3;
Display the updated measurement model and measurement noise.
disp(KF.MeasurementModel);
1 0 0 0 0 0 0 0 1 0 0 0
disp(KF.MeasurementNoise)
3 0 0 3
Use the distance
function to lock the updated measurement model.
distance(KF,[100;0])
ans = 3.3165
Correct the filter's state estimation using a new measurement vector with different size and display the updated state covariance matrix.
correct(KF,[100;0]); disp(KF.StateCovariance);
1.2857 0.8571 0 0 0 0 0.8571 1.5714 0 0 0 0 0 0 1.2857 0.8571 0 0 0 0 0.8571 1.5714 0 0 0 0 0 0 2.2500 1.5000 0 0 0 0 1.5000 2.0000
Updating Measurement and Measurement Noise Size for Constant Velocity Extended Kalman Filter
Initialize the constant velocity Extended Kalman Filter (EKF) using an objectDetection
object.
mp = struct('Frame', 'spherical', ... 'HasElevation', false, 'HasVelocity', false); detection = objectDetection(0,[0;100], ... 'MeasurementParameters',mp); filter = initcvekf(detection);
Predict the state of the filter after 1 second and use the distance function to lock the measurement function.
predict(filter, 1); distance(filter,[0;100],{mp});
Display the filter's measurement noise and state covariance matrix.
disp(filter.MeasurementNoise);
1 0 0 1
disp(filter.StateCovariance);
1.0e+03 * 0.1013 0.1005 0 0 0 0 0.1005 0.1010 0 0 0 0 0 0 0.1033 0.1005 0 0 0 0 0.1005 0.1010 0 0 0 0 0 0 8.3371 0.1005 0 0 0 0 0.1005 0.1010
To update the filter's measurement and noise sizes, use the setMeasurementSizes
function.
setMeasurementSizes(filter,3,3);
Set the measurement noise to 2, which will scalar expand into a 3-by-3 matrix. Display the updated measurement noise for verification.
filter.MeasurementNoise = 2; disp(filter.MeasurementNoise);
2.0000 0 0 0 2.0000 0 0 0 2.0000
Use the distance
function to lock the updated measurement function.
distance(filter,[100;0;0])
ans = 18.3226
Correct the filter's state estimation using a new measurement vector with different size and display the updated state covariance matrix.
correct(filter,[100;0;0]); disp(filter.StateCovariance);
1.9613 1.9467 0 0 0 0 1.9467 3.1768 0 0 0 0 0 0 1.9620 1.9089 0 0 0 0 1.9089 5.0777 0 0 0 0 0 0 1.9995 0.0241 0 0 0 0 0.0241 99.7888
Input Arguments
filter
— Filter for object tracking
trackingKF
object | trackingEKF
object | trackingUKF
object | trackingCKF
object | trackingGSF
object | trackingIMM
object
Filter for object tracking, specified as one of these objects:
trackingKF
— Linear Kalman filtertrackingEKF
— Extended Kalman filtertrackingUKF
— Unscented Kalman filtertrackingCKF
— Cubature Kalman filtertrackingGSF
— Gaussian-sum filtertrackingIMM
— Interacting multiple model (IMM) filter
Note
When using setMeasurementSizes
with trackingKF
, the trackingKF
filter must be initialized
with the largest possible sizes for measurement and measurement noise.
measurementSize
— Size of the measurement
positive real integer
Expected size of the measurement, specified as a positive real integer.
measurementNoiseSize
— Size of the measurement noise
positive real integer
Expected size of the measurement noise, specified as a positive real integer.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2024b
See Also
clone
| correct
| correctjpda
| distance
| initialize
| likelihood
| residual
| predict
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)