low-pass filtering a signal within a range determined by signal amplitude

조회 수: 3 (최근 30일)
Hi all,
I have this problem (see the picture attached). The baseline is noisy, so I have applied a lowpass filter (1 Hz, y=lowpass(I_P,1,6250). The data looks amazing but the spikes are smaller (of course, because I applied a low-pass filter).
So, in short, I want to apply the same low-pass filter (1Hz) exclusively to the baseline, i.e. from -10 pA to + 50 pA, so that the data baseline is improved signal-wise, and the spike amplitude remains untouchable (keeping the real amplitude).
The signal inside the green box is the data I want to filter. The signal inside the red box is the data I do not want to filter.
Thanks

채택된 답변

Mathieu NOE
Mathieu NOE 2020년 12월 15일
hello Jose
so this is a little code snipset, it uses a windowing technique as low pass filter
the peaks are left as original
you can leave the peks very sharp (one point) or wider if you leave the following line active :
hope it helps !!
%% signal generation
signal = 10*randn(1,samples); % noise
% add some peaks (must NOT be filtered)
signal(100) = 400;
signal(200) = 300;
signal(300) = 200;
signal = myslidingavg(signal, 5); % just a trick to make the peaks a bit wider (optionnal)
%% main code
% sliding avg method
threshold = max(abs(signal))/4;
ind = find(signal< threshold);
out = myslidingavg(signal(ind), 100);
signal_out = signal;
signal_out(ind) = out;
figure(2),
plot(time,signal,'b',time,signal_out,'r');
  댓글 수: 7
Jose Rego Terol
Jose Rego Terol 2020년 12월 15일
Dear Mathieu,
At the beginning, I was sceptic about the utility of your code for my needs.
I have been playing around with your code. Now, I understand that this is what I need.
Please, let me encourage you to submit this code to File Exchange. It would be beneficial for everyone in our situation, and you just submitted here in this thread. Then, why don´t you make it more visible, more accessible?
In short, good job and thanks for sharing this code with me.
Best,
Jose
Mathieu NOE
Mathieu NOE 2020년 12월 15일
hi again
glad it finally helped you
to be honest with you and with the person you originally developped the function almost 20 years ago, this was available in the FEX under :
I just improved marginaly the function essentially for my own needs, and more recently to help other people
but I wont take credit for someone else work !
there are also alternatives like fast moving_average.m that seems even more powerful - have to try this one

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by