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: rls_init.m
    path of file: ./repos/fieldtrip/realtime/online_mri/private
    
    the code of the file until where you have to start completion: function model = rls_init(dimX, dimY, gamma, lambda)
% function model = rls_init(dimX, dimY [, gamma = 1e-6 [, lambda = 1]])
%
% Initialise a recursive least squares model with input dimension dimX and output dimension dimY.
% The optional third parameter sets the regularisation coefficient (as in ridge regression).
% The optional fourth argument sets the forgetting factor (1 = no forgetting).
%
% See also RLS_UPDATE, RLS_PREDICT

% Straightforward but slow equations:
%
% model.H    = model.H + x*x';
% model.XtY  = model.XtY  + x*y';
% model.beta = inv(model.H) * model.XtY;
%
% RLS works by directly accumulating the inverse of H and also updating beta without 
% computing XtY
%
% (C) 2010 S.Klanke

    
function model = rls_init(dimX, dimY, gamma, lambda)
% function model = rls_init(dimX, dimY [, gamma = 1e-6 [, lambda = 1]])
%
% Initialise a recursive least squares model with input dimension dimX and output dimension dimY.
% The optional third parameter sets the regularisation coefficient (as in ridge regression).
% The optional fourth argument sets the forgetting factor (1 = no forgetting).
%
% See also RLS_UPDATE, RLS_PREDICT

% Straightforward but slow equations:
%
% model.H    = model.H + x*x';
% model.XtY  = model.XtY  + x*y';
% model.beta = inv(model.H) * model.XtY;
%
% RLS works by directly accumulating the inverse of H and also updating beta without 
% computing XtY
%
% (C) 2010 S.Klanke

if nargin<3
  gamma = 1e-6;
elseif gamma <= 0
  error 'Regularisation parameter must be positive'
end