How can I use "impulseest" to recreate the results of the deprecated "impulse" function?

5 views (last 30 days)
I have been using the "impulse" function to calculate impulse responses in the time domain, but I recently switched to R2013a, and I now get this warning when I run my code:
Warning: The use of the "impulse" command on a dataset or FRD model is deprecated. Generate a non-parametric impulse response model from the data using the "impulseest" command. Apply the "impulse" command on the resulting model if required.
I tried to do as the warning suggested, and I rewrote my code to use "impulseest," but I can't recreate the results I got with the deprecated impulse function.
I wrote some code to demonstrate the issue I'm having. I make an input signal of random impulses, create a desired impulse response, and convolve the input with the impulse response to get the output. I then use "impulse" and "impulseest" to try to recover the desired impulse response. You'll see that this does not work with the "impulseest" function.
data_length = 4000; % length of data in samples
impulse_length = 250; % length of fabricated impulse response
fs = 100; % sampling frequency
ni = 20; % number of impulses
time = -(impulse_length/fs/2):(1/fs):(impulse_length/fs/2);
% Create a random distribution of impulses; this will be the input
stimes = round(rand(ni,1)*data_length);
in = zeros(data_length,1);
in(stimes) = 1;
% Create a window, which will be the impulse response we hope to recover
g_win = gausswin(impulse_length+1);
s_win = sin(2*pi*10*(1:(impulse_length+1))/impulse_length+1)';
win = g_win.*s_win;
% Convolve the window with the input to create the output
out = conv(in, win, 'same');
% Use deprecated "impulse" function to calculate impulse response
data = iddata(out, in, 1/fs);
h = impulse(data, [min(time) max(time)]);
[impulse_y1,impulse_t1] = impulse(h, time);
% Use "impulseest" to calculate the impulse response
h2 = impulseest(data,2*max(time)*fs, min(time)*fs);
[impulse_y2,impulse_t2] = impulse(h2, time);
% Plot results
figure; subplot(311); plot(time, win)
title('Fabricated impulse response')
subplot(312); plot(impulse_t1,impulse_y1);
title('Output of impulse function')
subplot(313); plot(impulse_t2,impulse_y2)
title('Output of impulseest function')
Is there some way to choose the parameters for "impulseest" to recover the desired impulse response? I am definitely interested in looking at feedback (values before t=0), and this seems to be part of the problem. Thanks!

Answers (2)

Paul
Paul on 18 Jan 2014
Edited: Paul on 18 Jan 2014
Well, there is impulseestOptions where you can define input offset. I don't know much about this problem so can't help you much more. Although I think 2*max(time)*fs should be [] in impulseest. The options can be set something like this:
opt = impulseestOptions('InputOffset',min(time));
h2 = impulseest(data,opt);

BL
BL on 23 Jan 2014
Thanks for your answer, Paul. That's a good idea, but it doesn't seem to solve the problem. It looks like InputOffset adjusts the amplitude of the impulse response, rather than shifting it in time.
I think part of the problem is that the old "impulse" function estimated the impulse response by creating an idarx model, while the new one uses an idtf model. So they seem to approach the problem in different ways.
I have found one solution, however. Rather than using the "impulseest" function, I can recover the desired impulse response (with no warnings from MATLAB) by creating a polynomial model using "polyest":
h2 = polyest(data, [0 impulse_length 0 0 0 0], 'InputDelay', -impulse_length/2);
[impulse_y2,impulse_t2] = impulse(h2, time);
Now the problem is that "impulse" does the calculation in 1.92 seconds, while "polyest" takes 10.42 seconds...
BL

Categories

Find more on Linear Model Identification 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!