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: calc_avg.m
    path of file: ./repos/HRTF-Individualization/model/matlabcode/functions/depricated/gui_exp
    
    the code of the file until where you have to start completion: function [ output_args ] = calc_avg( input_args )


%% Calc Averaged DTF Magnitude
avg_dtf_left = zeros(offset,length(current_positions));
avg_dtf_right = zeros(offset,length(current_positions));
avg_hrir_left = zeros(hrir_db_length,length(current_positions));
avg_hrir_right = zeros(hrir_db_length,length(current_positions));

set(handles.play_positions,'String',{[1:length(current_positions)],'all'});
set(handles.play_positions,'Value',length(current_positions)+1);

    
function [ output_args ] = calc_avg( input_args )


%% Calc Averaged DTF Magnitude
avg_dtf_left = zeros(offset,length(current_positions));
avg_dtf_right = zeros(offset,length(current_positions));
avg_hrir_left = zeros(hrir_db_length,length(current_positions));
avg_hrir_right = zeros(hrir_db_length,length(current_positions));

set(handles.play_positions,'String',{[1:length(current_positions)],'all'});
set(handles.play_positions,'Value',length(current_positions)+1);

switch(get(handles.calc_mode,'Value'))
    
case 1 % PCA1
    
    avg_DATA_PCA = mean(DATA_PCA);
    
    c =0;
    for pos=1:length(current_positions)

        if (get(handles.pca_mode,'Value') <= 2) % PCA DTF MODE
            c=c+1;
            avg_dtf_left(:,pos) = avg_DATA_PCA((c-1)*offset+1:c*offset);

            c=c+1;
            avg_dtf_right(:,pos) = avg_DATA_PCA((c-1)*offset+1:c*offset);

            % Find matching phase and mean
            rms_error_l = zeros(database_size_real,1);
            rms_error_r = zeros(database_size_real,1);

            for i=1:database_size_real       
            rms_error_l(i) = rmse(avg_dtf_left(:,pos),DATA_PCA(i,(c-2)*offset+1:(c-1)*offset));
            rms_error_r(i) = rmse(avg_dtf_right(:,pos),DATA_PCA(i,(c-1)*offset+1:c*offset));
            end