How to detect point before a positive ramp
Show older comments
Hi all,
I have a stimulation signal (current mA) that is like the picture below:

So it is made by peaks. Please find below a zoom of one pulse:

My goal is to find the point in the red circle, so the last point before the positve ramp of the peak
How can i do that?
Thanks a lot for your help and time
KR
Accepted Answer
More Answers (1)
Using this File Exchange submission
threshold=2.5; %to separate background from signal
locations = groupLims(groupTrue(yourSignal>threshold), 1 )-1
9 Comments
Francesco Lucarelli
on 15 Jul 2021
Matt J
on 15 Jul 2021
Nope, but why does it matter? The functions are free.
Mathieu NOE
on 15 Jul 2021
hi @Matt J
your idea is brilliant and I'm impressed with the result
however , I found the code working great if your signal has almost vertical slope , like here

but if the data is more progressive , the location of the "kirk" points is incorrect :
%% dummy data
% repetition frequency of 3 Hz and a sawtooth width of 0.1 sec.
% The signal is to be 1 second long with a sample rate of 1kHz.
Fs = 1e3;
t = 0 : 1/Fs : 1; % 1 kHz sample freq for 1 sec
D = 0 : 1/5 : 1; % 5 Hz repetition freq
y1 = pulstran(t,D,'rectpuls',0.02);
y1 = y1 + 0.03*randn(size(y1)); % add some noise
y1 = smoothdata(y1,"gaussian",20);
threshold=0.5; %to separate background from signal
locations = groupLims(groupTrue(y1>threshold), 1 ) -1;
locations = locations(locations>0);
figure(1)
plot(t,y1,'b',t(locations),y1(locations),'dr','linewidth',2,'markersize',12);
legend('signal 1',' "kirk" points' );
xlabel('Time(s)');

Francesco Lucarelli
on 15 Jul 2021
Edited: Francesco Lucarelli
on 15 Jul 2021
Mathieu NOE
on 15 Jul 2021
hello again
well, can you share your data , so we can better help you ?
Mathieu NOE
on 15 Jul 2021
second question : as we may use some signal filtering that can cause some phase distorsion, what is the time accuracy you need on these data ?
Francesco Lucarelli
on 15 Jul 2021
Edited: Francesco Lucarelli
on 15 Jul 2021
Mathieu NOE
on 15 Jul 2021
what is that matlab function : stim ?
stim(locp(i))>0.5
Francesco Lucarelli
on 15 Jul 2021
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


