Sum, then filter, then re-separate data

조회 수: 2 (최근 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 CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by