close all
clear all

K = 17.633;  %Pulses per Liter
PsiPerVolt = .5;  %Nominal.

FlowRate = [0 31 60 72 58 19 7.5 30 65 72];  %Hz
PressureDrop = [0.028 0.38 1.00 1.29 .94 .18 .06 .35 1.11 1.33]; %V
PressureDrop = PressureDrop-PressureDrop(1)*ones(size(PressureDrop));

FlowRate = FlowRate*60/K;  %LitersPerMin
PressureDrop = PressureDrop*PsiPerVolt;

figure
plot(FlowRate,PressureDrop,'x');
xlabel('Flow Rate (LPM)');
ylabel('Pressure Drop (psi)');


p = polyfit(FlowRate,PressureDrop,2)

x = 0:250;
y = polyval(p,x);

hold all
plot(x,y);
plot(x,1.75*p(1)*x.*x,'-k');

legend('Data','2nd Order Polynomial Fit to Data','Quadratic Fit to Data','Location','NorthWest');

grid on;
print('-dpdf','PressureDropTest1.pdf');