Code covered by the BSD License  

Highlights from
Demonstration of Fourier transformation

image thumbnail

Demonstration of Fourier transformation

by

 

19 Apr 2010 (Updated )

The first file construct signals from Fourier terms The second file analyzes actual signals

fourier1(Wave_Form,No_of_Terms)
function fourier1(Wave_Form,No_of_Terms)
%The input arguments to this software are the wave_form 
%which takes the values of  (1, 2, 3, 4, and 5)rectangular, 
%triangular, saw tooth, half wave, or full wave, signal forms.
%The second input argument is the number of terms to be included 
%in the calculation. It can be any number grater than one. 
%The out put of the program is a plot of all wave components and their sum.
close all
signn=1;
z=Wave_Form;
N=No_of_Terms;
t=0:pi/1000:2*pi;
if z==1
    for n=1:2:N
    y(n,:)=4*(1/n)*sin(n.*t)/pi;
end
plot(t,y')
hold
plot(t,sum(y),'.-k')
end
if z==2
    for n=1:2:N
    y(n,:)=signn*8*(1/n^2)*sin(n.*t)/pi^2;
    signn=signn*(-1);
end
plot(t,y')
hold
plot(t,sum(y),'.-k')
end
if z==3
    for n=1:N
    y(n,:)=-(1/n)*sin(n.*t)/pi;
    
end
plot(t,y')
hold
plot(t,sum(y),'.-k')
end
if z==4
    for n=2:2:2*N
        y(n,:)=-(2/pi)*cos(n*t)/((n-1)*(n+1));
end
plot(t,y')
hold
U=(1/pi)+.5*sin(t)+sum(y);
plot(t,.5*sin(t));
plot(t,U,'.-k')
plot(t,1/pi,'r')
end
if z==5
    for n=2:2:2*N
        y(n,:)=-(4/pi)*cos(n*t)/((n-1)*(n+1));
end
plot(t,y')
hold
UU=2/pi;
plot(t,UU,'r')
U=(2/pi)+sum(y);
plot(t,U,'.-k')
end
grid
xlabel('wt')
ylabel('amplitudes (arbitrary normalized units)')

Contact us