function kfStepMatrices2
extends Modelica.Icons.Function;
import Modelica;
import Modelica_LinearSystems2;
import Modelica_LinearSystems2.Math;
import Modelica_LinearSystems2.DiscreteStateSpace;
input Real A[:, size(A, 1)] "Transition matrix of the discrete system";
input Real C[:, size(A, 1)] "Output matrix of the discrete system";
input Real P[size(A, 1), size(A, 1)] "State covariance matrix of the previous instant";
input Real Q[size(A, 1), size(A, 1)] "Input or process noise covariance matrix of the previous instant";
input Real R[size(C, 1), size(C, 1)] "Output or measurement noise covariance matrix of the previous instant";
output Real K[size(A, 1), size(C, 1)] "Kalman filter gain matrix";
output Real P_new[size(A, 1), size(A, 1)] "Updated state covariance matrix";
end kfStepMatrices2;