Why do I randomly get an error while using the butter filter

4 visualizzazioni (ultimi 30 giorni)
I'm going through a pretty big pile of saved audio data (3 000 000 datapoints in 4 channels) recorded in 96 kHz in junks and I need to filter the data in order to discover whether the neccessary frequency was received.
I'm going through the data at 240 points at a time (all 4 channels simultanuasly)
Now sometimes (and not always) I get an error while using the butter function:
Error using * Inner matrix dimensions must agree.
Error in butter>buttnum (line 171) b = real(b*(kern*den(:))/(kern*b(:)));
Error in butter (line 125) num = buttnum(btype,n,Wn,Bw,analog,den);
Error in real_time_test_4_vk (line 132) [b,a] = butter(4, [9600 10560]/(fs/2), 'bandpass');
other times I get this error: Error using eig EIG did not converge.
Error in poly (line 26) e = eig(x);
Error in butter (line 124) den = poly(a);
Error in real_time_test_4_vk (line 132) [b,a] = butter(4, [9600 10560]/(fs/2), 'bandpass');
Does anybody know what the problem might be?
EDIT: I forgot to mention I use Matlab 2013a and am on Windows 7 64bit.

Risposta accettata

Star Strider
Star Strider il 30 Lug 2014
If you’re always using the same passband, design your filter once (use buttord to help define it), convert it to second-order-section (sos) implementation, save the sos structure in a ‘.mat’ file, and then load it to use it with filtfilt in your file processing function.
I couldn’t reproduce your error, but then you said it was intermittent.
Example (run this once, possibly in a separate file):
Wp = [9600 10560]/(fs/2);
[n,Wn] = buttord(Wp, [0.925 1.025].*Wp, 1, 50);
[b,a] = butter(n, Wn, 'bandpass');
[sos1,g1] = tf2sos(b,a);
save('Filter_1.mat', 'sos1', 'g1');
in your filtering script:
load('Filter_1.mat');
y = filtfilt(sos1,g1,x)

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by