Chung Kennedy Filter Data
CSV file
Tiff File

%The Fourier file

 

position = 0.03 ; %This is the centre of our filter

width = 0.0025; %This is the width of our filter

X=linspace(0,pi(),1000); %This is our X data in real space

random=rand(1,1000); %This is some noise

Y=((random-.5))+sin((60*X)); %This is our noisy data in real space

subplot(3,2,1); %setting up th plot

plot(X,Y); %plot our data

axis([0 .25 -2 2]); %set up the axis

title('A Sine wave with noise'); %Give the plot a title

[temp L]=size(X); %Get the number of X data points

T=1/1000; %Set up a scaling factor to plot frequency space

t = (0:L-1)*T; %Set up our frequency space X data

Fy=fft(Y); %perform a fourier transform of our data

maxv=max(abs(Fy)); %Find the maximum of the FFT, we use the abs

subplot(3,2,2); %function because the FFT gives us imaginary numbers

plot(t,abs(Fy)); %plot the FFT using the abs function

axis([0 .1 0 500]); %set up the axis

title('The Fourier transform of the data'); %give it a title

window=Gausf([0 maxv position width ],t); %Here we use the gaussian you made earlier

subplot(3,2,3); %This just shows the position

plot(t,window,'r',t,abs(Fy),'b'); %and width of the gaussian

axis([0 .1 0 500]); %with respect to the Fourier

actualwindow=Gausf([0 1 position width ],t); %transform I actually make two

title('Fourier with a filter on top'); %gaussians one for the plot called window

%and one to use use for the

%filter called actualwindow

%the difference is just the

%scale

YY=actualwindow.*Fy; %if we multiple the gaussian by the

%fourier transform it acts

%as acts as afilter

%selecting on the part of

%the fourier transform we

%are interested in we plot

%that here

subplot(3,2,4);

plot(t,abs(YY));

axis([0 .1 0 maxv]);

title('Filtererd Fourier');

FF=ifft(YY); %This is the clever bit we perform

%a reverse fourier

%transform of our filtered

%data and this is plotted

%here with the original

%data

subplot(3,2,5);

plot(X,real(2*FF),X,Y,'-.');

axis([0 .5 -1.5 1.5]);

title('Our filtered data and the original');

subplot(3,2,6);

plot(X,real(2*FF));

axis([0 .25 -1.25 1.25]);

title('The filtered data, ta da');

Computing