Why is filtic/arburg not working how I intend it to?

2 views (last 30 days)
So I'm trying to construct a simple autoregressive algorithm that can predict the output samples for a sine wave using the Burg method. My issue is that I have a discontinuity at the start and end, and perhaps I am incorrect, but I believe it is to do with the initial conditions being set incorrectly to the filter.
The reconstructed output looks like this:
As you can see from the bottom figure the filter is starting with an initial sample value of 0.5 rather than what should be around 0.9.
Here is my code:
% Begin Burg Method process
coef_number = 3;
burg_start_coef = arburg(x_start, coef_number);
burg_end_coef = arburg(x_end, coef_number);
start_cond = filtic(1, burg_start_coef, x_start);
end_cond = filtic(1, burg_end_coef, x_end);
start_result = filter(1, burg_start_coef, zeros(1, counter), start_cond);
end_result = filter(1, burg_end_coef, zeros(1, counter), end_cond);
xfade = zeros(1, counter);
for i = 1:counter
xfade(i) = 0.5*cos(i*pi/counter) + 0.5;
end
start_result = start_result.*xfade;
end_result = end_result.*xfade;
% Flip the end array so it is no longer reversed
end_result = fliplr(end_result);
result = start_result + end_result;
x_predicted(1:3000) = x_corrupted(1:3000);
x_predicted(3001:4000) = result;
x_predicted(4001:N) = x_corrupted(4001:N);
% Plot initial extrapolations
subplot(5, 1, 1)
plot(start_result)
subplot(5, 1, 2)
plot(end_result)
subplot(5, 1, 3)
plot(xfade)
subplot(5, 1, 4)
plot(result)
subplot(5, 1, 5)
plot(x_predicted)
Any help would be greatly appreciated, I'm pretty new to these functions.

Accepted Answer

Greg Dionne
Greg Dionne on 30 Jan 2017
You'll want to flip the order of the samples in your call to filtic.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!