Error with butter function

8 次查看(过去 30 天)
Olumide Adedeji
Olumide Adedeji 2021-4-2
编辑: Jan 2021-4-6
I have been having this problem for a while now on my matlab 2020b while using the butter function to create a bandpass filter for a continous waveform seismogram. My input is in accordance to what is in the documentation
I created a bandpass filter function first
function [ ts ] = bandpassfilt( ts, dt, high, low )
[n ,q] = size(ts);
tap = tukeywin(n, 0.1);
[b,a] = butter(1,[low, high].*(2*dt),'bandpass');
for i = 1:q
ts(:, i) = single(filtfilt(b,a,double(ts(:, i).*tap).*tap));
end
end
clc
clear
close all
Then created a script named "quick filt" to filter and plot
load trace
%samples and timing
sps = 250; %node sample rate
dt = 1/sps;
%data_samps = 60*60*250;
% body wave filter bandwidth ~0.5-2 Hz
P_low = .5;
P_high = 2;
dat_filt_Z_p = bandpassfilt(trace', dt, P_high, P_low);
%% quick plot
figure
subplot(2,1,1)
plot(trace)
title('Unfiltered')
subplot(2,1,2)
plot(dat_filt_Z_p)
title('Filtered')
It gives the error
Error using *
Inner matrix dimensions must agree.
Error in butter>buttnum (line 179)
b = real(b*(kern*den(:))/(kern*b(:)));
Error in butter (line 133)
num = buttnum(btype,n,Wn,Bw,analog,den);
Error in bandpassfilt (line 7)
[b,a] = butter(1,[low, high].*(2*dt),'bandpass');
Error in quick_filt (line 16)
dat_filt_Z_p = bandpassfilt(trace', dt, P_high, P_low);
I am also getting errors for using the lines of code given as example in the documentation
Input
low=0.5;
high=2;
dt=1/250;
[b,a] = butter(1,[low, high].*(2*dt));
Error
Index exceeds matrix dimensions.
Error in zp2ss (line 131)
a1 = t\[-den(2) -den(3); 1 0]*t;
Error in butter (line 97)
[a,b,c,d] = zp2ss(z,p,k);
  4 个评论
Mathieu NOE
Mathieu NOE 2021-4-6
Well, you probably should ask the technical support of the vendor....
DGM
DGM 2021-4-6
Is it possible that the function butter() has been overloaded?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by