Band-pass filter extraction.
Dear all, How are you?
Currently, I’m dealing with a band-pass filter that extracts a specific frequency band from a synthetic time series. Unfortunately, my band-pass filter is not extracting the original series as the following code shows. I would appreciate any suggestions on how to make the filter process more effective.
clear all,close all;
Inertial_period = 20.215;
K1_period = 24; % K1 period (hours)
M2_period = 12;
Inertial_amplitude = 1.0;
K1_amplitude = 0.3;
M2_amplitude = 0.5;
Inertial_phase = 0; % Example phase (radians)
K1_phase = pi/4;
M2_phase = pi/2;
% Time Vector (1 Month)
Fs = 1; % Sampling frequency (1 sample per hour)
duration_hours = 510; % 510 Hours
t = 0:1/Fs:duration_hours;
% Generate Components
I = Inertial_amplitude * cos(2*pi*t/Inertial_period + M2_phase);
K1 = K1_amplitude * cos(2*pi*t/K1_period + K1_phase);
M2 = M2_amplitude * cos(2*pi*t/M2_period + M2_phase);
u = K1+M2+I; %Time Serie
clearvars -except u I;
Now, I built a band-pass filter to extract the original signal "I" from the time series ‘u’.
Fs = 1; % 1 sample per hour
In = 20.215;
low_cutoff = 1/(In+1); % I + 1hour
high_cutoff = 1/(In-1); % I – 1Hour
% Normalize the cutoff frequencies by the Nyquist frequency (Fs/2)
Wn = [low_cutoff, high_cutoff] / (Fs/2);
% Design the Butterworth bandpass filter
[b, a] = butter(2, Wn, ‘bandpass’);
clear Fs low_cutoff_I high_cutoff_I Wn_I
fu = filtfilt(b,a,u);
Clearly, the band-pass filter with a central frequency +/- 1 hour is more accurate than the same band-pass filter with +/- 0.2 hours, but it is not identical to the original signal (orange). Is there any way I can better extract the frequency so the filtered signal will be almost identical to the original? Thanks to all; I would appreciate any suggestions.Dear all, How are you?
Currently, I’m dealing with a band-pass filter that extracts a specific frequency band from a synthetic time series. Unfortunately, my band-pass filter is not extracting the original series as the following code shows. I would appreciate any suggestions on how to make the filter process more effective.
clear all,close all;
Inertial_period = 20.215;
K1_period = 24; % K1 period (hours)
M2_period = 12;
Inertial_amplitude = 1.0;
K1_amplitude = 0.3;
M2_amplitude = 0.5;
Inertial_phase = 0; % Example phase (radians)
K1_phase = pi/4;
M2_phase = pi/2;
% Time Vector (1 Month)
Fs = 1; % Sampling frequency (1 sample per hour)
duration_hours = 510; % 510 Hours
t = 0:1/Fs:duration_hours;
% Generate Components
I = Inertial_amplitude * cos(2*pi*t/Inertial_period + M2_phase);
K1 = K1_amplitude * cos(2*pi*t/K1_period + K1_phase);
M2 = M2_amplitude * cos(2*pi*t/M2_period + M2_phase);
u = K1+M2+I; %Time Serie
clearvars -except u I;
Now, I built a band-pass filter to extract the original signal "I" from the time series ‘u’.
Fs = 1; % 1 sample per hour
In = 20.215;
low_cutoff = 1/(In+1); % I + 1hour
high_cutoff = 1/(In-1); % I – 1Hour
% Normalize the cutoff frequencies by the Nyquist frequency (Fs/2)
Wn = [low_cutoff, high_cutoff] / (Fs/2);
% Design the Butterworth bandpass filter
[b, a] = butter(2, Wn, ‘bandpass’);
clear Fs low_cutoff_I high_cutoff_I Wn_I
fu = filtfilt(b,a,u);
Clearly, the band-pass filter with a central frequency +/- 1 hour is more accurate than the same band-pass filter with +/- 0.2 hours, but it is not identical to the original signal (orange). Is there any way I can better extract the frequency so the filtered signal will be almost identical to the original? Thanks to all; I would appreciate any suggestions. Dear all, How are you?
Currently, I’m dealing with a band-pass filter that extracts a specific frequency band from a synthetic time series. Unfortunately, my band-pass filter is not extracting the original series as the following code shows. I would appreciate any suggestions on how to make the filter process more effective.
clear all,close all;
Inertial_period = 20.215;
K1_period = 24; % K1 period (hours)
M2_period = 12;
Inertial_amplitude = 1.0;
K1_amplitude = 0.3;
M2_amplitude = 0.5;
Inertial_phase = 0; % Example phase (radians)
K1_phase = pi/4;
M2_phase = pi/2;
% Time Vector (1 Month)
Fs = 1; % Sampling frequency (1 sample per hour)
duration_hours = 510; % 510 Hours
t = 0:1/Fs:duration_hours;
% Generate Components
I = Inertial_amplitude * cos(2*pi*t/Inertial_period + M2_phase);
K1 = K1_amplitude * cos(2*pi*t/K1_period + K1_phase);
M2 = M2_amplitude * cos(2*pi*t/M2_period + M2_phase);
u = K1+M2+I; %Time Serie
clearvars -except u I;
Now, I built a band-pass filter to extract the original signal "I" from the time series ‘u’.
Fs = 1; % 1 sample per hour
In = 20.215;
low_cutoff = 1/(In+1); % I + 1hour
high_cutoff = 1/(In-1); % I – 1Hour
% Normalize the cutoff frequencies by the Nyquist frequency (Fs/2)
Wn = [low_cutoff, high_cutoff] / (Fs/2);
% Design the Butterworth bandpass filter
[b, a] = butter(2, Wn, ‘bandpass’);
clear Fs low_cutoff_I high_cutoff_I Wn_I
fu = filtfilt(b,a,u);
Clearly, the band-pass filter with a central frequency +/- 1 hour is more accurate than the same band-pass filter with +/- 0.2 hours, but it is not identical to the original signal (orange). Is there any way I can better extract the frequency so the filtered signal will be almost identical to the original? Thanks to all; I would appreciate any suggestions. time series, matlab MATLAB Answers — New Questions