DSPRelated.com
Forums

freqresp with fft command

Started by ilke...@yahoo.com November 8, 2006
Hi,

I want to identify a system's parameters from time domain response. To do this, i want to find frequency response function of the system by using time domain response(impulse response). I compare the result of fft with real freq. resp. function value(by "freqresp" command), but these are not same.

My code is here :

%constructing system
A=[-0.8 -16;1 0];
B=[0.2;0];
C=[-0.8 -16];
D=0.2;
sys=ss(A,B,C,D);

%freq.response.values with freqresp command
w = [0:1:80];
H = freqresp(sys,w);
Hs=squeeze(H);
Has(Hs);

%freq.resp.values with applying fft to impulse response of sys.
t=0:0.01:10;
h=impulse(sys,t);
Fs = 100; % Sampling frequency
T = 1/Fs; % Sample time
L = length(h); % Length of signal
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(h,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
Ha2=2*abs(Y(1:NFFT/2));
w1=2*pi*f;
figure
plot(w1,Ha2,'b',w,Ha,'r')
As seen from plot, results are not same, but in theory these must be same, my code can be wrong, could you help me ?

Thanks..