Find data between min and max
Mostrar comentarios más antiguos
Hello there,
I have used the two functions islocalmin and islocalmax to find minimum and maximum points in my data.
TFmin = islocalmin(task, 'MinProminence',10)
TFmax = islocalmax(task, 'MinProminence',10)
plot(time_s,task, time_s (TFmin),task(TFmin),'r*')
hold on
plot(time_s,task,time_s(TFmax),task(TFmax),'b*')
I have identified different points as you can see in the attached plots, and I ended up with 10 points.
Now, I need to create two variables (task + time_s) repressing the data that lies in between each minimum and maximum point.
For example (see attached pic):
I need extract the exact date of time and task between the points:
1 and 2
3 and 4
5 and 6
7 and 8
9 and 10
And also the opposite:
2 and 3
4 and 5
6 and 7
8 and 9
Any advice or help would be much appreciated.
Thank you
Respuesta aceptada
Más respuestas (1)
Jeremy
el 30 de En. de 2020
Something like this?
t = linspace(0,2*pi,201);
y = sin(t);
plot(t,y,'LineWidth',2)
grid on
hold on
minid = find(islocalmin(y));
maxid = find(islocalmax(y));
[~,d] = min([minid maxid])
switch d
case 1
data_id = minid:1:maxid;
case 2
data_id = maxid:1:minid;
end
t_int = t(data_id);
y_int = y(data_id);
plot(t_int,y_int,'r--','LineWidth',2)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
