fileloadpath = ['\\atlas.shore.mbari.org\projectlibrary\' ...
    '901805_Coastal_Biogeochemical_Sensing\Spray_Data\24802901\' ...
    '\QC\24802901_QC.mat'];
filesavepath = 'C:\Users\bwerb\Documents\dep_24802901\QCPlots_QC\diag';
load(fileloadpath,'s');
n = length(s.sdn);
xvars = {'Ik','Ib','vrs','vk','vrs_std','vk_std'};
yvar = {'pres'};
xlabels = {'Ik','Ib',...
    'vrse', 'vk', 'vrse std', 'vk std'};

for profile = 1:n      
    figure(1)
    clf
    tl = tiledlayout(2,3);
    title(tl,['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('QCPlot_profile_%d.png', profile));
    
    % Save the figure as a PNG file
    saveas(gcf, filename)
end