How to use bandpass filter.

2 views (last 30 days)
Dung Nguyen
Dung Nguyen on 24 Jun 2019
Commented: Dung Nguyen on 13 Jul 2021
I have a data set which includes 2 columns: one is time (in month) and one is values that need analysics. I need to used bandpass filer to filter signal and obtain quasi-beninial oscillation (QBO) as figure 6(in attach). The period of this QBO is from 22 to 34 months, centered at 28 months. I try wirte a code but I don't belive on it. I would like everyone to check help me. My data, code, figure in attach. I hope everyone can help me.

Accepted Answer

Mathieu NOE
Mathieu NOE on 8 Jul 2021
Hello
no bugs or special issues , but minor improvements
I prefer to use the IIR filters (like butter) used with filtfilt
clc;clear all;close all
load RTEC_N1.txt
time=RTEC_N1(:,1);
RTEC=RTEC_N1(:,2);
%% dt
dt = mean(diff(time));
% fnorm_12=[1./28 1./24];
Fs=1/dt;
fc1 = 1./30;
fc2=1./22;
Wn = (2/Fs)*[fc1 fc2];
% Wn = [(2/Fs)*fc1 (2/Fs)*fc2];
% b = fir1(10,Wn,'low',kaiser(11,3));
% wn=[1./30 1./22];
% [b,a] = fir1(75,Wn);
% [b,a] = fir1(80,Wn,'bandpass');
% wn=1./(fs/2)/26
[b,a]=butter(2,Wn);
yy = filtfilt(b,a,RTEC);
% yy = filter(b,a,RTEC);
% figure(1);
% plot(time,RTEC,time,y,time,yy)
% legend('Original','filtfilt','filter');grid on;
plot(time,RTEC,'b',time,yy,'r');grid on;hold on;
fid1=fopen('RTIME_Sfiltertry1.txt','w');
for i=1:length(time)
fprintf(fid1,'%10.3f\t%10.4f\r\n',time(i),yy(i));
end
fclose(fid1);
  8 Comments
Mathieu NOE
Mathieu NOE on 13 Jul 2021
hello
well, your eyes are more powerful than any spectral analysis tool !! some tools are more appropriate than others for non stationnary signals (like wavelet vs fft) , but as already said above, there is some trace of the 26-28 month period signal but it's weak; does it means there is a problem with the data ? honestly , i cannot say because my field of expertise is more industrial vibration analysis and control , rather than weather or oceanographic data .
I may come to the point where my help is coming to and end - sorry for that
Dung Nguyen
Dung Nguyen on 13 Jul 2021
Hello
Thanks for your help.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!