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: confussions_gm.m
    path of file: ./repos/HRTF-Individualization/model/matlabcode/functions/exp
    
    the code of the file until where you have to start completion: function [cjdg,fb_conf,ud_conf,fb_conf_full,ud_conf_full] = confussions_gm(jdg,loc,tol1,tol2,tol3,crc)

% jdg: individual judgements; azimuth [-+ 180], elevation [-90 to 270]

% tol1: tolerance front/back front
% tol2: tolerance front/back back
% tol3: tolerance up/down

    
function [cjdg,fb_conf,ud_conf,fb_conf_full,ud_conf_full] = confussions_gm(jdg,loc,tol1,tol2,tol3,crc)

% jdg: individual judgements; azimuth [-+ 180], elevation [-90 to 270]

% tol1: tolerance front/back front
% tol2: tolerance front/back back
% tol3: tolerance up/down
% crc: if 1 then correct judgements in matrix cjdg

% Calculate Error and Front-Back Confusions
cjdg = jdg;
fb_conf = zeros(2,size(loc,1),size(loc,2));ud_conf = zeros(2,size(loc,1),size(loc,2));
fb_conf_full = zeros(size(loc,1),size(loc,2));ud_conf_full = zeros(size(loc,1),size(loc,2));
for l = 1:size(loc,1) % locations
    for t = 1:size(loc,2) % trials
        % Front-Back Confusions
        if loc(l,t,1) < 0 % Left Hemishphere
            if ( (loc(l,t,1) >= (-90-tol1)) && (loc(l,t,1) <= (-90+tol1)))  % target inside IAA exclusion zone
                % ignore
            else
%             if loc(l,t,1)~= -90 % Exclude locations directly on the side
                if (loc(l,t,1) > - 90) && (loc(l,t,1) > (-90+tol1)) % Front and Outside Conf Zone
                    if (jdg(l,t,1) < - 90) && (jdg(l,t,1) < 0)  || (jdg(l,t,1) > 90) && (jdg(l,t,1) > 0) % Target Outside Tolerance                        
                        fb_conf(1,l,t) = 1;
                        fb_conf_full(l,t) = 1;
                        if crc == 1
                            if (jdg(l,t,1) < - 90) && (jdg(l,t,1) < 0)
                                cjdg(l,t,1) = - 90 - (jdg(l,t,1) + 90);
                            elseif (jdg(l,t,1) > 90) && (jdg(l,t,1) > 0)
                                cjdg(l,t,1) = 90 - (jdg(l,t,1) - 90);
                            end