function [inv]=COFilter(data)

%This M-file will take in the CO2 data provided on Garcia's website,
%perform a fourier transform, filter out the components closest to 1 cycle
%per year, and transform back to the time domain

freqdata=fft(data);     %perform DFT on data 

N=length(data);         %Number of Samples
Fs=24;                  %24 samples per year
t=(1:N)/Fs;             %time increments (years)
tau=1/Fs;               %Sampling time 1 year per 24 samples
f=(0:N-1)*(Fs/N);       %Frequency values

for i=1:(N/2)
    
    if floor(f(i))==1                                 %Frequency is nearly 1 cycle per year
        freqdata(i)=0;freqdata(i-1)=0;                              %Kill componet
        freqdata(N+2-i)=0;freqdata(N+3-i)=0;                              %Kills its reflection about Nyquist frequency
        break;    
    end
    
end

inv=ifft(freqdata);                           %Take inverse transform back to time domain
plot(t,data,'b',t,inv,'r');
Title('CO2 Concentration In Parts Per Million (?)');
xlabel('Years');ylabel('Atmospheric C02 (Parts Per Million?)');
legend('Actual Data','Filtered Data');

     