You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: localization_ekf_update.m
    path of file: ./repos/libDirectional/lib/external/ukfm/examples/localization
    
    the code of the file until where you have to start completion: function [up_state, up_P] = localization_ekf_update(state, P, y, R)
%LOCALIZATION_EKF_UPDATE Update step
%
% Syntax: [up_state, up_P] = localization_ekf_update(state, P, y, R)
%
% Inputs:
%    state - state
%    P - covariance matrix
%    y - measurement
%    R - noise covariance matrix
%
% Outputs:
%    up_state - updated state
%    up_P - updated covariance matrix

% Observability matrix
H = [zeros(2, 1) eye(2)];

% measurement uncertainty matrix
S = H*P*H' + R;

% gain matrix
K = P*H' / S;

% innovation

    
function [up_state, up_P] = localization_ekf_update(state, P, y, R)
%LOCALIZATION_EKF_UPDATE Update step
%
% Syntax: [up_state, up_P] = localization_ekf_update(state, P, y, R)
%
% Inputs:
%    state - state
%    P - covariance matrix
%    y - measurement
%    R - noise covariance matrix
%
% Outputs:
%    up_state - updated state
%    up_P - updated covariance matrix

% Observability matrix
H = [zeros(2, 1) eye(2)];

% measurement uncertainty matrix
S = H*P*H' + R;

% gain matrix
K = P*H' / S;

% innovation
xi = K * (y-localization_h(state));

% update state
up_state = localization_phi(state, xi);

% update covariance
up_P = (eye(3)-K*H)*P;
end