How to use bandpass filter.
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Mathieu NOE
2021-7-8
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 个评论
Mathieu NOE
2021-7-13
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!