필터 지우기
필터 지우기

How i use the command Butter?

조회 수: 11 (최근 30일)
Marcelo Costa
Marcelo Costa 2012년 11월 13일
I have two questions. The first question is: How do I choose the cutoff frequency of the Butterworth filter The second question is how to filter this data? Attached the link to download the data? https://docs.google.com/open?id=0BzSixbWRFmQLbmRRSC0tUEdMMlU
Thank you. I use this algorith
for m=1:endoffile
[a,b]=butter(4,6(210/2), 'low')
exit(1:4,m)=filter(d,f,arq(1:4,m))
However, the results are very different from the actual data.
  댓글 수: 3
Daniel Shub
Daniel Shub 2012년 11월 14일
In general masking built-in functions with variables is a bad idea. Masking EXIT is only asking for problems.
Marcelo Costa
Marcelo Costa 2012년 11월 20일
I forgett 6/(210/2). 6 is a cutoff frequency and 210 is acquisition frequency. I try using this code now: [b,a] = butter(4,6/(210/2)); arq2=filtfilt(b,a,arq(:,m)); and the error is: Error using filtfilt>getCoeffsAndInitialConditions (line 149) Data must have length more than 3 times filter order.
Error in filtfilt (line 67) [b,a,zi,nfact,L] = getCoeffsAndInitialConditions(b,a,Npts);
Error in testefiltro (line 12)
arq2=filtfilt(b,a,arq(m,:));

댓글을 달려면 로그인하십시오.

채택된 답변

Wayne King
Wayne King 2012년 11월 20일
You cannot use filtfilt unless your input vector is more than 3 times as long as your coefficient vectors (the order of your filter).
Because filtfilt works on the columns of your data matrix, you need to transpose your data matrix assuming that you want your filter to operate on the dimension with 37 samples, not 4
  댓글 수: 1
Marcelo Costa
Marcelo Costa 2012년 11월 20일
I made this and working.
Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Wayne King
Wayne King 2012년 11월 13일
편집: Wayne King 2012년 11월 13일
Nobody can answer how to choose the cutoff frequency for you. That depends on your filter design. Suppose I wanted to filter data below 150 Hz and the data were sampled at 1 kHz. I would do the following. First I'll create some data and then filter it.
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
[B,A] = butter(10,150/(1000/2));
y = filter(B,A,x);
If you want to view the magnitude response of your Butterworth filter, enter:
fvtool(B,A,'Fs',1000)
Obviously you have to use the correct sampling frequency.

Marcelo Costa
Marcelo Costa 2012년 11월 20일
Hello Again This is my command.
clear all
f2=12.5; frequency of cutoff
Fs=210; acquisition frequency
Files=dir('*.txt');
[z,n]=size(Files);
for x=1:z
arq=load(Files(x).name);
[v,p]=size(arq);
for m=1:p;
[b,a] = butter(4,f2/(Fs/2));
arq2=filtfilt(b,a,arq(:,m));
res=arq -arq2;
end
savefile=['filtrado','.',Files(x).name];
save(fullfile(savefile),'res','-ASCII');
end
my txt files is saved like this 4 rows X 37 coluns.
But always appers this msg Error using filtfilt>getCoeffsAndInitialConditions (line 149) Data must have length more than 3 times filter order.
Error in filtfilt (line 67) [b,a,zi,nfact,L] = getCoeffsAndInitialConditions(b,a,Npts);

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by