Using FFT for linear convolution in frequency domain
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to find the system response given a periodic input (in this example it is cos(t)) I have an impulse response, h and an input force, f.
My code works, but the plot is incorrect! the amplitude is way off of what it should be, so i believe i am using fft wrong.
Please help me find my error!!
clear
%system parameters
m=4;
k=256;
c=1;
wn=sqrt(k/m);
z=c/2/sqrt(m*k);
wd=wn*sqrt(1-z^2);
w=sqrt(4*k*m-c^2)/(2*m);
x0=0; %initial conditions
v0=0;
%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:.01:10*pi ;%time vector
f=cos(t); %force f
F=fft(f);
h=1/m/wd*exp(-z*wn*t).*sin(wd*t); %impulse response
H=fft(h);
conv=H.*F; %convolution is multiplication in freq domain
plot(t,ifft(conv))
I have read things about zero-padding for linear convolution. I am not sure how to implement this, maybe this is why i am getting weird results?
Thanks!
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!