HW10: Difference between revisions

From Class Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:




close all
<pre>close all
clear all
clear all
f = 2; % sine wave frequency
f = 2; % sine wave frequency
Line 24: Line 24:
sigA = fft([sig1 Zmat]);
sigA = fft([sig1 Zmat]);
sigB = fft([sig2 Zmat]);
sigB = fft([sig2 Zmat]);
sigC = real(ifft(sigA.*sigB));
sigC = real(ifft(sigA.*sigB));</pre>

Revision as of 17:03, 2 December 2009

Problem Statement

Present an Octave (or MATLAB) example using the discrete Fourier transform (DFT).

Solution

I decided to show a cross correlation example using MATLAB.


close all
clear all
f = 2; % sine wave frequency
tmax = 2; % go to 2 seconds
theta = pi/4;
T = 0.01; 
t = 0:T:tmax;
N = length(t);
Nmat = 0:N-2;
Zmat = Nmat *0;
sig1 = sin(2*pi*f*t); % A alpha signal
sig2 = sin(2*pi*f*t); % A beta signal
c= conv(sig1,sig2); %test of matrix size
%zeropad both vectors to length N1+N2-1 to avoid cyclic convolution
sigA = fft([sig1 Zmat]);
sigB = fft([sig2 Zmat]);
sigC = real(ifft(sigA.*sigB));