Skip to content

Instantly share code, notes, and snippets.

@HosikChae
Created April 7, 2022 12:19
Show Gist options
  • Save HosikChae/58e388b3fcb8f069ca35dfe717c9bf44 to your computer and use it in GitHub Desktop.
Save HosikChae/58e388b3fcb8f069ca35dfe717c9bf44 to your computer and use it in GitHub Desktop.
Template for Kalman Filter implemented in Simulink Interpreted Function block
function y = KF(x)
% reference: https://www.mathworks.com/help/matlab/ref/persistent.html
persistent A B C D dt m1 l1 R Q P0 P;
% only executed at the first time -> initialization
if isempty(P)
% A = ...; B = ...; C = ...; D = ...;
% R = ...; Q = ...; P0 = ...;
% m1 = ...; l1 = ...; dt = ...;
end
%% do KF
% Prediction
% ...
% Innovation
% ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment