Using FFT for linear convolution in frequency domain
조회 수: 11 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!