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: CBIG_TRBPC_plot_avg_relevance.m
    path of file: ./repos/CBIG/stable_projects/predict_phenotypes/ChenTam2022_TRBPC/figure_utilities/matrix_plots
    
    the code of the file until where you have to start completion: function CBIG_TRBPC_plot_avg_relevance(path_fc,path_list_var,...
    list_cog,list_pers,list_ment_health,scalelim,path_out)
% CBIG_TRBPC_plot_avg_relevance(path_fc,path_list_var,...
%     list_cog,list_pers,list_ment_health,scalelim,path_out)
% 
% This function will average together FC relevance values and plot them to produce
% the predictive feature matrices
% 
% Required inputs:
% - path_fc: a string for a path to a .mat file that contains a 
%         structure `struct_fc_vec` with the following fields:
%         `rs`, `mid`, `sst`, `nback`, where each field contains a matrix of
%         size 87571 x b, where b is the number of predicted behaviors
% - path_list_var: a string for a path to a .txt file that contains a list
%         of the predicted behaviors
% - list_cog: a cell array of strings for the cognitive cluster, 
%         where each string is one predicted behavior from `path_list_var`
% - list_pers: a cell array of strings for the personality cluster,
%         where each string is one predicted behavior from `path_list_var`
% - list_ment_health: a cell array of strings for the mental health cluster,
%         where each string is one predicted behavior from `path_list_var`
% - scalelim: a vector containing two numbers specifying the minimum and maximum
%         values for the plots. If left empty, the default is [-2 2]
% - path_out: a string for a path to the output director
%
% Written by Angela Tam & CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md


%% add required paths to functions
addpath(fullfile(getenv('CBIG_CODE_DIR'),...
    'stable_projects','disorder_subtypes','Tang2020_ASDFactors',...
    'step3_analyses','utilities'));

if ~exist(path_out), mkdir(path_out); end

load(path_fc)

if isempty(scalelim)
    scalelim = [-2 2];
end


    
function CBIG_TRBPC_plot_avg_relevance(path_fc,path_list_var,...
    list_cog,list_pers,list_ment_health,scalelim,path_out)
% CBIG_TRBPC_plot_avg_relevance(path_fc,path_list_var,...
%     list_cog,list_pers,list_ment_health,scalelim,path_out)
% 
% This function will average together FC relevance values and plot them to produce
% the predictive feature matrices
% 
% Required inputs:
% - path_fc: a string for a path to a .mat file that contains a 
%         structure `struct_fc_vec` with the following fields:
%         `rs`, `mid`, `sst`, `nback`, where each field contains a matrix of
%         size 87571 x b, where b is the number of predicted behaviors
% - path_list_var: a string for a path to a .txt file that contains a list
%         of the predicted behaviors
% - list_cog: a cell array of strings for the cognitive cluster, 
%         where each string is one predicted behavior from `path_list_var`
% - list_pers: a cell array of strings for the personality cluster,
%         where each string is one predicted behavior from `path_list_var`
% - list_ment_health: a cell array of strings for the mental health cluster,
%         where each string is one predicted behavior from `path_list_var`
% - scalelim: a vector containing two numbers specifying the minimum and maximum
%         values for the plots. If left empty, the default is [-2 2]
% - path_out: a string for a path to the output director
%
% Written by Angela Tam & CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md


%% add required paths to functions
addpath(fullfile(getenv('CBIG_CODE_DIR'),...
    'stable_projects','disorder_subtypes','Tang2020_ASDFactors',...
    'step3_analyses','utilities'));

if ~exist(path_out), mkdir(path_out); end

load(path_fc)

if isempty(scalelim)
    scalelim = [-2 2];
end

% get the names of the behaviours from path_list_var
% read text file line by line and write it into cell_array
ll = 0;
fid = fopen(path_list_var);
while (~feof(fid))
    ll = ll + 1;
    list_behav_orig{ll} = fgetl(fid);
end