function varData = gather_NavData(fileList,indices, variableName)
    % GATHERARCHIVE Extracts a variable with a given name from a list of .h5 files
    %
    % Inputs:
    %   - fileList: A cell array of strings representing the file names or paths
    %               of the .h5 files to extract the variable from
    %   - variableName: A string representing the name of the variable to extract
    %
    % Output:
    %   - varData: A cell array of matrices representing the values of the
    %              variable in each of the .h5 files

    % Initialize the output variable
    varData = cell(length(fileList), 1);

    % Loop through each file in the list
    for i = 1:length(fileList)
            [path, filename, ext] = fileparts(fileList{i});
            h5_path = strrep(path, '/PBLH','/Archive_drop/Archive/');
            h5_file = strcat(filename,'.h5');
            full_path_h5 = strcat(h5_path,h5_file);


        try
            % Try reading the variable directly
            idx = indices{i};
            variable = h5read(full_path_h5, variableName);
            varData{i} = variable(idx);
        catch
            idx = indices{i};
            variable = h5read(full_path_h5, ['/Nav_Data/' variableName]);
            varData{i} = variable(idx);
        end
    end 


end







