Update the Kalman Filter in Simulink model

  Kiến thức lập trình

I want to creat a Filter in Simulink. For example:

filter = trackingKF('MotionModel', '2D Constant Acceleration', 'State', zeros(6, 1));

Then in simulink model, I want to update the filter and predict the states after receive feedback during the simulation. The function is defined as:

function predictedState = Predict(x,y)
    
    % Receive feedback about the present position
    presentPosition = [x;y]; 
    
    % Correct step: Update the filter with observed position
    correct(filter, presentPosition);
    
    % Predict future positions after receiving feedback
    predictedState = predict(filter);
 
end

My problem is: How to define this Filter in Simulink that can be updated by using ‘correct’ command, and how can I build a structure that can update this filter using my above function during my simulation.
Thank you for your helps !

I try to define the Kalman Filter in my Predict function but it seems not good because the filter need to be updated to become more precise. Can the callback function in Model Explorer give a help ?

New contributor

Minh Duc Pham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT