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

[ff,cc]=fourier2(SR,T)
function [ff,cc]=fourier2(SR,T)
%This file can acquire data from any signal voltage connected to the
%line-in port of the computer sound card (this should not exceed
%a peak value of one volt), perform fast Fourier transformation 
%and produce plot and numerical data of the frequency spectrum 
%of the signal. 
%The input arguments are SR which is the signal sampling rate. 
%This can be between 8000 and 44000, and the period of time T in seconds during which the signal is sampled it can range between 0.001 sec up to few seconds.
%The output data are the data ff, and cc used in plotting the frequency 
%spectrum

ai=analoginput('winsound')   
   addchannel(ai,1:2);
   ai.samplerate=SR;
   ai.samplespertrigger=SR*T;
     ai.triggertype='immediat';
   start(ai);
   [d,t]=getdata(ai);
   N=length(t);
   u1=d(:,1);
   y=fft(u1,1024);
   p=y.*conj(y);
   c=(p.^(1/2));
   ff=[1:1024]*N/(max(t)*1024);
   cc=c/max(c);
   plot(ff(1:512),cc(1:512))
   grid
   delete(ai)
clear ai




Contact us