//www.basicairdata.eu Example Uncertainty calculation for Pitot
//Scilab 5.4.1
//(c)2013 JLJ  
//Data from example Pitot
uc=0.005;
uq=5;// [Pa]
urho=0.04;//[kg/m3] <-EXtendend Uncertainty due to worst case 
//Worst case at max height 100m (see your local regulations) 
//751 mmHg Atmospheric pressure, temp range -//20Â°C +50Â°C, max T reading error 0.6Â°C max error in
//Ambient pressure 100Pa 
//Relative Humidity fixed to 50%
c=1;
q=500;//[Pa] Pressure reading
rho=1.225;//[kg/m3]

V=linspace(10,90,90) //Airspeed [m/s]
//IAS/TAS function
function y=F(x)
  y=[(2/x(1)*x(2)/x(3))^0.5];
endfunction
i=1;
for id=V
    q=0.5*c*rho*id^2
    x=[c;q;rho];
    sdIAS=[uc;uq;urho*0]; 
    [J]=derivative(F,x)
    uIAS(i)=(J^2*sdIAS^2)^0.5
    sdTAS=[uc;uq;urho]; 
    [J]=derivative(F,x)
    uTAS(i)=(J^2*sdTAS^2)^0.5
//    printf("IAS Uncertainty %.1f [m/s] at %.1f [m/s]\n",uIAS(i),id)
//    printf("TAS Uncertainty %.1f [m/s] at %.1f [m/s]\n",uTAS(i),id)
    i=i+1;     
end
plot2d(V,uIAS,2)
plot2d(V,uTAS,3)
xtitle('IAS uncertainty (blue) TAS uncertainty (green) Vs Airspeed www.basicairdata.eu 2013 JLJ')
xlabel('Airspeed[m/s]')
ylabel('Uncertainty magnitude [m/s]')
xgrid();
