Sum, then filter, then re-separate data

5 ビュー (過去 30 日間)
LukeJes
LukeJes 2022 年 10 月 1 日
コメント済み: Star Strider 2022 年 10 月 2 日
Hi all,
Trying to get some help with a problem I'm having:
I have two vectors that, when summed together, create a signal that has noise (spikes) that I'm wanting to filter out.
I need to filter the summed signal and then revert it back to the two vectors such that they can be re-summed without any noise.
Not sure if this is possible or if anyone has any ideas? I've attached some images and a .mat file with the data contained.

採用された回答

Star Strider
Star Strider 2022 年 10 月 1 日
編集済み: Star Strider 2022 年 10 月 2 日
It would help to have the sampling frequency.
I am not certain what you want to filter, however for now I am assuming that is the noise in the valley between the summed signals —
LD = load(websave('data','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141660/data.mat'))
LD = struct with fields:
front: [20000×1 double] rear: [20000×1 double]
front = LD.front;
rear = LD.rear;
Fs = 2000; % Default Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(front);
t = linspace(0, L-1, L)/Fs; % Time Vector
NFFT = 2^nextpow2(L); % For Efficiency
FTfr = fft([front rear]-mean([front rear]),NFFT)/L; % Fourier Transform
Fv = linspace(0, 1, NFFT/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector (One-Sided Fourier Transform)
figure
plot(Fv, abs(FTfr(Iv,:))*2)
grid
xlabel('Frequency (Units)')
ylabel('Magnitude (Units)')
title('Fourier Transform')
xlim([0 Fs/100])
lim1 = [min([front rear]); max([front rear])]; % Signal Limits
Fco = 5; % Cutoff Frequency
fr_filt = lowpass([front rear], Fco, Fs, 'ImpulseResponse','iir'); % Filter Signals
lim2 = [min(fr_filt); max(fr_filt)]; % Signal Limits
fr_filt = max(fr_filt-9, 0); % Eliminate Baseline Transients
lim3 = [min(fr_filt); max(fr_filt)]; % Signal Limits
fr_filt = fr_filt .* lim1(2,:)./lim3(2,:); % Rescale Data
lim3 = [min(fr_filt); max(fr_filt)]; % Check Signal Limits
figure
plot(t, fr_filt)
grid
xlabel('Time')
ylabel('Amplitude')
title('Filtered Signals')
figure
plot(t, sum(fr_filt,2))
grid
xlabel('Time')
ylabel('Amplitude')
title('Summed Filtered Signals')
This lowpass filter eliminates the noise reasonably well, at the expense of eliminating some other high-frequency information. That can be fine-tuned (to an extent) by changing the cutoff frequency ‘Fco’ in the lowpass call. Since I am not certain what you want to filter out, I leave that fine-tuning to you. I will help as necessary to get the desired result.
NOTE — Since I do not have the actual sampling frequency, I have scaled everything here in terms of it so this code should work with a different sampling frequency without alteration.
EDIT — (2 Oct 2022 at 03:34)
Added known sampling frequency, adjusted ‘Fco’ and thresholded the result to attenuate the baseline transients after filtering.
.
  4 件のコメント
LukeJes
LukeJes 2022 年 10 月 2 日
Exactly what I was looking for! Thanks again for your time.
Star Strider
Star Strider 2022 年 10 月 2 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by