HW10: Difference between revisions
Jump to navigation
Jump to search
New page: '''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. |
No edit summary |
||
Line 6: | Line 6: | ||
I decided to show a cross correlation example using MATLAB. | 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)); |
Revision as of 18:00, 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));