# Frequency response, impulse response and fft

Discussion in 'MATLAB' started by Joli, Jul 16, 2007.

1. ### JoliGuest

I'd like to compute frequency response functions (FRF) from impulse
response functions (IRF). I thought that the Matlab fft function would
do the job. However, it is not working as I expected.

I wrote a script that computes the IRF of a 1-DOF mechanical system,
storing it in a vector. Then, the FRF vector is found by fft-ing the
IRF. However, when this result is compared with the analytical FRF
vector, we see that the two vectors are very different. Please, could
you help me to figure out the mistake I'm doing? The Matlab code is:

clear all
close all

% System properties
m1=1; k1=500; c1=5;
wn1=sqrt(k1/m1); zeta1=c1/m1/2/wn1; wd1=sqrt(1-zeta1^2)*wn1;

% Impulse response
t=linspace(0,10,1000);
h=1/m1*1/wd1*exp(-zeta1*wn1*t).*sin(wd1*t);

% FRF from impulse response
H=fftshift(fft(h));
Fs=1/(t(2)-t(1));
f=linspace(-Fs/2,Fs/2,length(t));

% Analytical FRF
w=2*pi*f;
G=1./(k1-m1*w.^2+sqrt(-1)*w*c1);

% Results
figure(1)
semilogy(f,abs(H)/length(H),'-r',f,abs(G),'-b')
legend('from IRF','analytical')
grid
xlabel('Freq. (Hz)')
ylabel('abs(H),abs(G)')
title('FRF')

Joli, Jul 16, 2007

2. ### Greg HeathGuest

I had a similar problem 5 years ago. See my extensive August 2002 post

greg-heath ifft-phase-correction

Hope this helps.

Greg

Greg Heath, Jul 17, 2007