function [wwf] = stitchFiles(folder, fileNames,savefile)

    % Initialize cell arrays to store intermediate results
    k0_timeseries_cell = {};
    Temperature_cell = {};
    Dissolved_Oxygen_cell = {};
    Pressure_cell = {};
    Practical_Salinity_cell = {};
    Sigma0_cell = {};
    pH_canyonB_cell = {};
    pH_tot_adj_cell = {};
    pH_free_adj_cell = {};
    dn_cell = {};
    
    % Loop through to get the data for each file
    for i = 1:length(fileNames)
        file = fullfile(folder, fileNames{i});
        load(file, 'ww')
        
        k0_timeseries_cell{end+1} = ww.k0_adj_full;
        Temperature_cell{end+1} = ww.Temperature;
        Dissolved_Oxygen_cell{end+1} = ww.Dissolved_Oxygen;
        Pressure_cell{end+1} = ww.Pressure;
        Practical_Salinity_cell{end+1} = ww.Practical_Salinity;
        Sigma0_cell{end+1} = ww.Sigma0;
        pH_canyonB_cell{end+1} = ww.pH_canyonB;
        pH_tot_adj_cell{end+1} = ww.pH_tot_adj;
        pH_free_adj_cell{end+1} = ww.pH_free_adj;
        dn_cell{end+1} = ww.Datenum;
    end
    
    % Concatenate the results from cell arrays into matrices
    max_rows = max(cellfun(@(x) size(x, 1), k0_timeseries_cell));
    max_cols = sum(cellfun(@(x) size(x, 2), k0_timeseries_cell));
    
    wwf.k0_timeseries = NaN(max_rows, max_cols);
    wwf.Temperature = NaN(max_rows, max_cols);
    wwf.Dissolved_Oxygen = NaN(max_rows, max_cols);
    wwf.Pressure = NaN(max_rows, max_cols);
    wwf.Practical_Salinity = NaN(max_rows, max_cols);
    wwf.Sigma0 = NaN(max_rows, max_cols);
    wwf.pH_canyonB = NaN(max_rows, max_cols);
    wwf.pH_tot_adj = NaN(max_rows, max_cols);
    wwf.pH_free_adj = NaN(max_rows, max_cols);
    wwf.Datenum = NaN(1, max_cols);
    wwf.depth = (-74:-2)';
    wwf.Latitude = 
    colstart = 1;
    for i = 1:length(k0_timeseries_cell)
        [rows, cols] = size(k0_timeseries_cell{i});
        colend = colstart + cols - 1;
        
        wwf.k0_timeseries(1:rows, colstart:colend) = k0_timeseries_cell{i};
        wwf.Temperature(1:rows, colstart:colend) = Temperature_cell{i};
        wwf.Dissolved_Oxygen(1:rows, colstart:colend) = Dissolved_Oxygen_cell{i};
        wwf.Pressure(1:rows, colstart:colend) = Pressure_cell{i};
        wwf.Practical_Salinity(1:rows, colstart:colend) = Practical_Salinity_cell{i};
        wwf.Sigma0(1:rows, colstart:colend) = Sigma0_cell{i};
        wwf.pH_canyonB(1:rows, colstart:colend) = pH_canyonB_cell{i};
        wwf.pH_tot_adj(1:rows, colstart:colend) = pH_tot_adj_cell{i};
        wwf.pH_free_adj(1:rows, colstart:colend) = pH_free_adj_cell{i};
        wwf.Datenum(1, colstart:colend) = dn_cell{i};
        
        colstart = colend + 1;
    end
    
    % Save the struct to a file if needed
    if savefile
        save('full_timeseries.mat', 'wwf');
    end
end