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월 2일
편집: Jan 2021년 4월 6일
hello
your code works on my R2020b without any issue
funny the my butter function does not have the
zp2ss
function in line 131 where your error appears , so I wonder if your version of butter is corrupt or ?
this is mine :
% [CODE removed due to:]
% Copyright 1998-2019 The MathWorks, Inc.
Olumide Adedeji
Olumide Adedeji 2021년 4월 6일
I really don't know to be honest, I even downgraded to 2018b and I am still getting thesame error
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개)

카테고리

제품

릴리스

R2020b

질문:

2021년 4월 2일

편집:

Jan
2021년 4월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by