function VcalibratedKnots=AS1Cessna182(VindicatedKnots,flap)
% function VcalibratedKnots=AS1Baron58(VindicatedKnots,flap)
% Correct indicated airspeed for instrument error and static position error.
% Data is extracted from Cessna 182 Owner's Manual.
% It is assumed that the Cessna 182 has zero instrument correction.
% Therefore 
%             Vinstrumentcorrected (Vic) = Vindicated (Vi)
% Given below are the position error corrections to get Vcalibrated. 
% They are a function of Vindicated and flap position.
%             Vcalibrated=f(Vindicated,flap)
%                   flap=0   for no flap
%                   flap=0.5 for half flap
%                   flap=1   for full flap
% Vindicated and Vcalibrated are a row vectors.
% Half flap data is the same as full flap data.
% Units are KNOTS.

Vimph=VindicatedKnots*1.150779;  % Convert knots to mph
%
%YI = INTERP1(X,Y,XI)
if flap<0.5
    IAS=[60 80 100 120 140 160 180]; % Tabulated data in mph
    CAS=[68 83 101 119 139 158 177]; % Tabulated data in mph
    Vcmph=interp1(IAS,CAS,Vimph);
else
    IAS=[40 50 60 70 80 90 100 110]; % Tabulated data in mph
    CAS=[55 60 66 74 83 92 102 111]; % Tabulated data in mph
    Vcmph=interp1(IAS,CAS,Vimph);
end    
VcalibratedKnots=Vcmph*0.868976;  % Convert back to knots
