Change frequency level after filter
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示

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
2015 年 5 月 14 日
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
2015 年 5 月 14 日
How to change it. Could you please to explain more. I'm using code like this
filter(2,0.01,x)
Star Strider
2015 年 5 月 14 日
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
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:

Star Strider
2015 年 5 月 14 日
What is the sampling frequency of your data?
Are:
a=y(:,1);
your sampling times?
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
Star Strider
2015 年 5 月 15 日
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
2015 年 5 月 15 日
Thank you very much. I has just fix it as you say. it work. Thank you one more time
Star Strider
2015 年 5 月 15 日
My pleasure!
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Modulation についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
