Algorithm that identifies the number of time steps in which a matrix has certain values?
1 次查看(过去 30 天)
显示 更早的评论
I have a 4001x1 matrix ODv (attached) and its 1x4001 timespan vector. As you can see in the attached image, every x milliseconds there is an action potential (in this case, they are the 4 bursts of activity you see where the y value increases from approximately -60mV to positive values).
I am looking for a way to measure how many milliseconds it takes for each action potential (whose number is variable, it might become 5 or 2 or whatever number depending on the conditions) to go from a value of -40mV (this number is the same for all 4 action potentials) to each peak value (this number changes for each action potential: approximately 40, 30, 30 and 30 mV in this image).
So for example I'd need an algorithm that tells me: it took 2 ms for the first AP, 3 ms for the second AP, 1 ms for the third AP and so on.
I would know how to do this for one AP, but not when there is more than one.
Thanks!
3 个评论
Atsushi Ueno
2021-4-17
This is a simple "findpeaks" function. However, it is only very ad hoc. Does it satisfy your purpose?
thr = -20; % for this ODv.mat only
peaks = ODv(1:end-2) < ODv(2:end-1) ...
& ODv(2:end-1) > ODv(3:end) ...
& ODv(2:end-1) > thr;
idx = find(peaks);
采纳的回答
Atsushi Ueno
2021-4-17
load('time.mat');
load('ODv.mat');
thr = -20; % for this ODv.mat only
thr2 = 2; % for this ODv.mat only
peaks = ODv(1:end-2) < ODv(2:end-1) ...
& ODv(2:end-1) > ODv(3:end) ...
& ODv(2:end-1) > thr;
botms = diff(diff(ODv) > thr2) == 1;
peak_time_span = tspan(find(peaks)) - tspan(find(botms));
peak_time_span =
0.6500 0.7250 0.7250 0.7250 0.7250
0 个评论
更多回答(1 个)
Cris LaPierre
2021-4-17
If you use a live script, you also can develop your own algorithm to find the points you want interactively using the Find Local minima and maxima live task. You do not need any toolboxes to use it.
It will return the indices of the peaks. Assuming you have vector of times as well, you can use that to find the corresponding times. From there, you can take the difference between the times (diff).
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!