First grahp í the source data. After I filter it, I got the grahp 2. But as you can see, in the second grahp, the yelow line(I don't know how to call it) is not the same with the 0-0 line(blue). So I want to change the frequency level from 0,5 to 0. How can I do it.
Thanks in advance

 채택된 답변

Star Strider
Star Strider 2015년 5월 14일

0 개 추천

You seem to be using a low-pass filter. Use a bandpass filter instead, with a low-frequency cutoff that will eliminate the D-C offset (value at 0 Hz), and with the high-frequency cutoff you used in your original low-pass filter.

댓글 수: 8

vu ngothanh
vu ngothanh 2015년 5월 14일
How to change it. Could you please to explain more. I'm using code like this
filter(2,0.01,x)
Use the filter design functions in the Signal Processing Toolbox to design your filter. The filter you are using with that filter call is actually not doing any filtering.
For example, your filter has b=2, a=0.01 and freqz plots it as:
b = 2;
a = 0.01;
figure(1)
freqz(b, a, 512)
I do not have your signal, and I do not know what frequencies you want your filter to pass, so I cannot be specific about your bandpass filter design.
vu ngothanh
vu ngothanh 2015년 5월 14일
편집: vu ngothanh 2015년 5월 14일
here is a part of my input data
0.000000,6.200694E-6,-1.875651E-6
3.906250E-5,1.195134E-5,3.528527E-6
7.812500E-5,6.992699E-6,-1.703543E-6
0.000117,9.885240E-6,8.637580E-8
0.000156,7.302614E-6,2.633568E-6
0.000195,1.484388E-5,9.827665E-6
0.000234,9.781935E-6,1.359972E-6
0.000273,9.954110E-6,2.633568E-6
0.000312,1.470614E-5,2.977783E-6
0.000352,9.024364E-6,3.617479E-7
0.000391,8.852189E-6,-3.611039E-7
0.000430,8.886624E-6,-2.922609E-7
0.000469,1.050507E-5,7.418159E-6
0.000508,1.056979E-7,-1.302822E-5
0.000547,5.133209E-6,-9.689335E-6
0.000586,1.109046E-5,4.216958E-6
0.000625,2.688323E-6,-5.248959E-6
0.000664,6.786089E-6,-1.152799E-6
0.000703,4.926599E-6,-8.243631E-6
0.000742,6.889394E-6,-2.922609E-7
0.000781,5.064339E-6,-4.987900E-7
0.000820,7.130439E-6,-6.143919E-6
0.000859,2.102928E-6,-3.699991E-6
This is my code:
y=load('vibration_019.txt');
a=y(:,1);
c=y(:,3);
b=y(:,2);
figure(1);
subplot(2,1,1);
plot(a,b);
subplot(2,1,2);
[B,A]=butter(2,0.01);
b1=filter(B,A,b);
plot(a,b1);
Now, when I fix the code as you said. the result like this
But, I want like this:
What is the sampling frequency of your data?
Are:
a=y(:,1);
your sampling times?
vu ngothanh
vu ngothanh 2015년 5월 15일
편집: vu ngothanh 2015년 5월 15일
a=y(:,1); %time
b=(y:,2); %value at point 1
b=(y:,2); %value at point 2
There is not enough data to test the filter, but there is enough available to design it. I designed a bandpass filter with a lower frequency cutoff of 500 Hz and an upper frequency cutoff of 10 KHz. That should do what you want it to.
The code:
a = y(:,1);
b = y(:,2);
c = y(:,3);
%
Ts = mean(diff(a)); % Analyse Signal Spectrum
Fs = 1/Ts;
Fn = Fs/2;
fa = fft(a)/length(a);
fb = fft(b)/length(b);
Fv = linspace(0, 1, fix(length(fa)/2)+1)*Fn;
Iv = 1:length(Fv);
%
figure(1) % Plot Fourier Transformed Signals
subplot(2,1,1)
plot(Fv, abs(fa(Iv)))
grid
subplot(2,1,2)
plot(Fv, abs(fb(Iv)))
grid
%
Wp = [500 10000]/Fn; % Design Bandpass Filter
Ws = Wp.*[0.8 1/0.8];
Rp = 1;
Rs = 10;
[n,Wn] = buttord(Wp, Ws, Rp, Rs);
[b,a] = butter(n,Wn);
[sos,g] = tf2sos(b,a);
%
figure(2)
freqz(sos, 128, Fs) % Check Filter Performance
%
bfilt = filtfilt(sos, g, b); % Filter Signals
cfilt = filtfilt(sos, g, c);
%
figure(3) % Plot Filtered Signals
subplot(2,1,1)
plot(a, bfilt)
title('Velocity 1 Filtered')
grid
subplot(2,1,2)
plot(a, cfilt)
title('Velocity 2 Filtered')
grid
The documentation for the filter design is in the Signal Processing Toolbox documentation. It is relatively straightforward.
vu ngothanh
vu ngothanh 2015년 5월 15일
Thank you very much. I has just fix it as you say. it work. Thank you one more time
Star Strider
Star Strider 2015년 5월 15일
My pleasure!

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

추가 답변 (0개)

카테고리

태그

질문:

2015년 5월 14일

댓글:

2015년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by