fileloadpath = '\\atlas.shore.mbari.org\ProjectLibrary\901805_Coastal_Biogeochemical_Sensing\Spray_Data\24802901\sat_files\24802901_sat.mat';
filesavepath = 'C:\Users\bwerb\Documents\dep_24802901\QCPlotsSat';
load(fileloadpath,'s');
n = length(s.sdn);
xvars = {'tc','psal','opt','pHin','doxy','PAR'};
yvar = {'pres'};
xlabels = {'Temperature (^oC)','Salinity (PSU)',...
    'Fluoresence', 'pHin', 'Doxy (\mumol/kg)', 'PAR'};

for profile = 1:n      
    figure(1)
    clf
    tl = tiledlayout(2,3);
    title(tl,['Sat QC plots 24802901, profile: ', num2str(profile)])
    
    for i = 1:6
        nexttile(tl)
        plot(s.(xvars{i})(:,profile),s.(yvar{1})(:,profile))
        xlabel(xlabels{i})
        grid on
        set(gca,'Ydir','reverse')
    end
    % Create the filename for saving the figure
    filename = fullfile(filesavepath, sprintf('QCPlotSat_profile_%d.png', profile));
    
    % Save the figure as a PNG file
    saveas(gcf, filename)
end