First element greater than
25 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
AAZ
el 17 de Ag. de 2022
Comentada: Star Strider
el 17 de Ag. de 2022
I have a set of data containing x,
How can i extract only the first value greater than x in this set.
0 comentarios
Respuesta aceptada
Star Strider
el 17 de Ag. de 2022
Try simething like this —
v = randi(9, 1, 20)
x = 7
first_x_idx = find(v > x,1,'first')
Result = v(first_x_idx)
.
2 comentarios
Star Strider
el 17 de Ag. de 2022
I am confused. I am not certain what you want.
I am not certain how robust this will be for other vectors, however here it gives the result you want —
v = [-0.1011 -0.0712 -0.0562];
x = -0.0599;
first_x_idx = interp1(v,(1:numel(v)),x,'previous')
Result = v(first_x_idx)
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!