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_PlotCorrMat_general.m
    path of file: ./repos/CBIG/utilities/matlab/figure_utilities/PlotCorrMat
    
    the code of the file until where you have to start completion: function CBIG_PlotCorrMat_general(res, corr_mat, parcelname, network_order_struct, scalelim)

% CBIG_PlotCorrMat_general(res, corr_mat, parcelname, network_order_struct, scalelim)
%
% This function is a general script which visualizes ROI2ROI correlation matrix of any parcellation.
% The correlation matrix <corr_mat> can contain subcortical ROIs.
% The original ROI order of <corr_mat> is defined by <parcelname>.
% The ROIs will be visualized with the network orderring which is defined as cell structure
% <network_order_struct>:
%  {{'Net1','Net2'}, %thick lines
%   {'Net3'}, %thick lines
%   {'Net4'}}

    
function CBIG_PlotCorrMat_general(res, corr_mat, parcelname, network_order_struct, scalelim)

% CBIG_PlotCorrMat_general(res, corr_mat, parcelname, network_order_struct, scalelim)
%
% This function is a general script which visualizes ROI2ROI correlation matrix of any parcellation.
% The correlation matrix <corr_mat> can contain subcortical ROIs.
% The original ROI order of <corr_mat> is defined by <parcelname>.
% The ROIs will be visualized with the network orderring which is defined as cell structure
% <network_order_struct>:
%  {{'Net1','Net2'}, %thick lines
%   {'Net3'}, %thick lines
%   {'Net4'}}
% Thin white lines will be drawn between different subnetworks. Thick white lines will be drawn 
% between different networks based on above <network_order_struct>. For the example above, the 
% white lines will be drawn as follows:
% Net1
% ------ thin line
% Net2
% ====== thick line
% Net3
% ====== thick line
% Net4
%
% Input:
%   - res: (scalar)
%       The number of CORTICAL ROIs. For example:
%       res = 400 (not 419!) for Schaefer400+19subcortical
%       res = 100 for Schaefer100 without subcortical
%       res = 114 for Yeo2011 17 networks with split components.
%
%   - corr_mat: (KxK matrix)
%       The ROI2ROI correlation matrix. K = res if there is no subcortical ROI, else K = res+M if
%       there are M subcortical ROIs. The corr_mat is assumes to be formated as follows:
%       If there is no subcortical ROI:
%       corr_mat = [ lh2lh lh2rh;
%                    rh2lh rh2rh; ]
%       If there are subcortical ROIs:
%       corr_mat = [ lh2lh       lh2rh       lh2subcor;
%                    rh2lh       rh2rh       rh2subcor;
%                    subcor2lh   subcor2rh   subcor2subcor;]                    
%
%   - parcelname: (resx1 cell vector)
%       The original order of cortical ROIs. For example:
%       parcelname = {'Net3_componnet1';
%                     'Net1_componnet1';
%                     'Net2_componnet1';
%                     'Net1_componnet2';
%                     'Net2_componnet2';
%                     'Net4_componnet1';}
%
%   - network_order_struct: (cell vector contains sub-cell elements)
%       The visualization order of cortical ROIs. Thick white grids will be drawn between sub-cells.
%       For example:
%       {{'Net1','Net2'}, %thick lines
%        {'Net3'}, %thick lines
%        {'Net4'}}        
%      
%   - scalelim: ([lim_min limmax])
%       The range of the colormap. The <scalelim> should be a 1x2 vector where <lim_min> and <lim_max>
%       are the mininum and maximum value of the range. By default, <lim_min> is the -1*maximum
%       abosulute value of corr_mat, <lim_max> is the maximum abosulute value of corr_mat.
%
% Examples:
% corr_mat = rand(6,6)-0.5;
% parcelname = {'Net3_componnet1';
%               'Net1_componnet1';
%               'Net2_componnet1';
%               'Net1_componnet2';
%               'Net2_componnet2';
%               'Net4_componnet1';}
% network_order_struct = {{'Net1','Net2'}, %thick lines
%                         {'Net3'}, %thick lines
%                         {'Net4'}} 
% CBIG_PlotCorrMat_general(6, corr_mat, parcelname, network_order_struct, [-0.5 0.5]);
%
% Written by Ruby Kong and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md

if(size(corr_mat,1) > res)
    disp(['Dimension of corr_mat is higher than res = ' num2str(res)])
    disp('Visualizing FC matrix with subcortical regions ...')
    disp('NOTE: the subcortical regions should be the last few ROIs in the input correlation matrix.')
    disp('NOTE: we will not reorder the subcortial ROIs.')
    subcortical_flag = 1;
elseif(size(corr_mat,1) == res)
    subcortical_flag = 0;
else
    error(['Dimension of corr_mat is higher than res = ' num2str(res)]);
end