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: icatb_dfnc_meta_state_analysis.m
    path of file: ./repos/gift/GroupICAT/icatb/icatb_helper_functions
    
    the code of the file until where you have to start completion: function meta_states_info = icatb_dfnc_meta_state_analysis(FNCdynflat, num_comps, varargin)
%% Meta state analysis
%
% Inputs:
% 1. FNCdynflat - Matrix of dimensions subjects x windows x component pairs
% 2. num_comps - Number of components/clusters
% 3. varargin - Arguments passed in pairs
% a. '
    
function meta_summary = getSummaryMetaStates(Tcs)
% Get summary from meta states
%
% Number of unique rows (NUM_STATES)
% Change in states (CHANGE_STATES)
% MAX L1 distance between rows (STATE_SPAN)
% SUM of L1 distances between successive states (TOTAL_DIST)

num_states = zeros(size(Tcs, 3), 1);
change_states = zeros(size(Tcs, 3), 1);
state_span = zeros(size(Tcs, 3), 1);
total_dist = zeros(size(Tcs, 3), 1);
for nS = 1:size(Tcs, 3)
    tmp = squeeze(Tcs(:, :, nS));
    d1 = icatb_pdist(tmp, 'all', 1);
    d2 = icatb_pdist(tmp, 'successive', 1);
    idx = unique(tmp, 'rows');
    num_states(nS) = size(idx, 1);
    change_states(nS) = sum(d2 ~= 0); %length(find(max(abs(tmp_diff')) ~= 0));
    state_span(nS) = max(d1);
    total_dist(nS) = sum(d2);
end