figure
hold on

cmap = colormap(jet(250));

x = datenum(G2029.LabviewDateTime)';
y = G2029.PressuredBar' ;
z = G2029.VRSVOLTS';

colorIndex = min(250, round(10 * G2029.ThermistorTemp(1)));
plot3(x, y, z, 'color', cmap(colorIndex,:));

set(gca, 'ydir', 'reverse');
zLimits = zlim;
set(gca, 'ztick', [zLimits(1):0.001:zLimits(2)+.001]);
view(3);
datetick('x', 'mmmdd HH:MM')
colorbar('Ticks', [0, 1], 'TickLabels', {'0 degC', '50 degC'})
grid on

%

figure
hold on

cmap = colormap(jet(500));

dataSize = size(cycle);
for i=1:dataSize(1)
    x = datenum(data{1,i}.LabviewDateTime)';
    y = data{1,i}.PressuredBar' ;
    z = data{1,i}.VRSVOLTS';

    colorIndex = min(500, round(20 * data{1,i}.ThermistorTemp(1,:)))
    plot3(x, y, z, 'color', cmap(colorIndex,:));
end

set(gca, 'ydir', 'reverse');
zLimits = zlim;
view(3);
datetick('x', 'mmmdd HH:MM')
colorbar('Ticks', [0, 1], 'TickLabels', {'0 degC', '50 degC'})
grid on

%

edges = 10:10:2000;
for i = 1:length(edges) - 1
    indexes = find ( (allPressuresDecr >= edges(i)) & (allPressuresDecr < edges(i+1)));
    SD(i) = std(allVrsDecr(indexes));
end
plot(SD)

[p, S, mu] = polyfit(allPressuresDecr, allVrsDecr, 5);
yFit = polyval(p, edges, S, mu);
figure
errorbar(edges, yFit, 2*SD(2:201))
hold on
plot(cycle(1,10).pressureDecr, cycle(1,10).VrsDecr)
title('All Pressure Decr Vrs fit with 2*SD Error Bars')
xlabel('Pressure (dBar)')
ylabel("Vrs (volts)")

%

edges = 10:10:2000;
for i = 1:length(edges) - 1
    indexes = find ( (allPressuresDecr >= edges(i)) & (allPressuresDecr < edges(i+1)));
    residualMean(i) = mean(allResidualsDecr(indexes));
    residualSD(i) = std(allResidualsDecr(indexes));
end
errorbar(edges(1:199), residualMean, 2*residualSD)
hold on
plot(cycle(1,10).pressureDecr, cycle(1,10).residualsDecr)