%*****************************************************************
% Decorrelate wind and motion data. Sequentially remove correlation
% between wind and platform acceleration/velocity for each axis. Cross
% correlation coefficients computed as in Edson 2011 GASEX paper.
Cua = cov(detrend(Result(1,:)),detrend(Platacc(1,:)));
muua = Cua(1,2)/Cua(2,2);
Result(1,:) = Result(1,:) - muua*detrend(Platacc(1,:));
Cuv = cov(detrend(Result(1,:)),detrend(Platvel(1,:)));
muuv = Cuv(1,2)/Cuv(2,2);
Result(1,:) = Result(1,:) - muuv*detrend(Platvel(1,:));

Cva = cov(detrend(Result(2,:)),detrend(Platacc(2,:)));
muva = Cva(1,2)/Cva(2,2);
Result(2,:) = Result(2,:) - muva*detrend(Platacc(2,:));
Cvv = cov(detrend(Result(2,:)),detrend(Platvel(2,:)));
muvv = Cvv(1,2)/Cvv(2,2);
Result(2,:) = Result(2,:) - muvv*detrend(Platvel(2,:));

Cwa = cov(detrend(Result(3,:)),detrend(Platacc(3,:)));
muwa = Cwa(1,2)/Cwa(2,2);
Result(3,:) = Result(3,:) - muwa*detrend(Platacc(3,:));
Cwv = cov(detrend(Result(3,:)),detrend(Platvel(3,:)));
muwv = Cwv(1,2)/Cwv(2,2);
Result(3,:) = Result(3,:) - muwv*detrend(Platvel(3,:));
%*****************************************************************