Using IFFT for obtaining time response of measured freq response
18 views (last 30 days)
Show older comments
Hello, I have numerical frequency response data (G(s=j2*pi*f), f) for a system. I want to obtain the impulse response in time domain. I should be able to obtain this using the IFFT function. But the scaling is not clear to me. Here is the code I am using. What am I missing? Thanks. Amit.
clc; close all;
fmax = 1e6;
L = 1024;
fdelta = 2*fmax/(L-1)
fgrid = [-fmax:fdelta:fmax]; %fmax = fs/2 => deltaT = 1/(2*fmax)
tau = 1/(2*pi*5e4)
% Y(s) = 1/(1+s.tau) Given Freq Domain data
Y = 1./(1+j*2*pi*fgrid*tau);
y_t = ifft((Y));
Tdelta = 1/(2*fmax);
t = [0:Tdelta:Tdelta*(length(y_t)-1)];
% compare with known time domain function
figure; plot(t, y_t, 'bx', t, exp(-t/tau), 'r');
grid; axis([0 1e-4 0 1])
0 Comments
Answers (4)
Rick Rosson
on 28 Dec 2011
Please try:
Fs = 2e6;
L = 1024;
dF = Fs/L;
f = (-Fs/2:dF:Fs/2-dF)';
s = j*2*pi*f;
Fc = 50e3;
alpha = 2*pi*Fc;
tau = 1/alpha;
Y = alpha./(s+alpha);
dt = 1/Fs;
t = dt*(0:L-1)';
y = L*ifft(ifftshift(Y));
x = exp(-t/tau);
HTH.
Rick
2 Comments
Rick Rosson
on 28 Dec 2011
Do you have access to either the Control Systems Toolbox or the Signal Processing Toolbox? If so, which one (or both)?
0 Comments
Rick Rosson
on 29 Dec 2011
I modified the code I posted earlier to correct the scaling factor:
Fs = 2e6;
L = 1024;
dF = Fs/L;
f = (-Fs/2:dF:Fs/2-dF)';
s = j*2*pi*f;
Fc = 50e3;
alpha = 2*pi*Fc;
tau = 1/alpha;
Y = alpha./(s+alpha);
dt = 1/Fs;
t = dt*(0:L-1)';
G = 2*pi;
y = G*abs(ifft(ifftshift(Y)));
x = exp(-t/tau);
figure;
plot(t,x,t,y);
HTH.
Rick
1 Comment
Greg Heath
on 30 Dec 2011
FFTing and IFFTing is tricky business because you have to be perfectly clear about original assumptions. For example, time domain signals contain N measurements at a sampling frequency
Fs. If the signal is real the corresponding nonnegative frequency spectrum measurements have a spacing df = Fs/N and
have either the range
f = df*[0:N/2], Neven
fmax = Fs/2
L = length(f) = N/2+1
with L odd when N is even
or
f = df*[0:(N-1)/2], N odd
fmax = Fs/2 - df/2
L = (N+1)/2
with L even when N is odd
Now since you seem to have L = 1024 measurements, my conclusion is that
N = 2*L + 1 = 2049 is odd
and
Fs = 2*N*fmax/(N-1) = 2.001e6
Hope this helps.
Greg
See Also
Categories
Find more on Pulsed Waveforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!