% Pressure Coefficient Data Processing
%
% 

load cp23015aoa0;

TEST=0;
AoA0X=cp23015aoa0.Xpanel;
AoA0Y=cp23015aoa0.Ypanel;
AoA0V=cp23015aoa0.V;
AoA0Cp=cp23015aoa0.Cp;
AoA0Cp2=AoA0Cp;

figure(1)
plot(AoA0X,AoA0Y);
axis equal
hold on

plot(AoA0X,AoA0Cp,'g');
hold off
% runs=6;
% for l=[1:runs]
%     for i=[1:length(AoA0Cp)-2]
%         deltax=AoA0X(i+2)-AoA0X(i);
%         deltaCp=AoA0Cp(i+2)-AoA0Cp(i);
%         slope=deltaCp/deltax;
%         intersect=(AoA0Cp(i)-(slope*AoA0X(i)));
%         
%         secantCp=intersect+slope*AoA0X(i+1);
%         AoA0Cp2(i+1)=(secantCp+AoA0Cp(i+1))/2;
%         
%         if TEST==1
%             figure(2)
%             plot(AoA0X,AoA0Cp)
%             axis([0 1 -1 1])
%             hold on
%             plot([0 AoA0X(i+2)],[intersect AoA0Cp(i+2)])
%             plot(AoA0X(i+1),AoA0Cp2(i+1),'r*')
%             
%             hold off
%             pause(.01)
%         end
%     end
%     AoA0Cp=AoA0Cp2;
[b,a] = butter(5,0.15);
Hd = dfilt.df2t(b,a);        %Direct-form II transposed structure
y = filter(Hd,AoA0Cp);
AoA0Cp = y;
    figure(1)
    hold on
    plot(AoA0X,AoA0Cp,'r')
    hold off
% end
