Borrar filtros
Borrar filtros

finding certain points in data

1 visualización (últimos 30 días)
harley
harley el 2 de Sept. de 2015
Comentada: harley el 3 de Sept. de 2015
hello,
if I have a row of data say:
x = 1, 1.4, 2, 2.2, 3, 3.7, 4.....
where the corresponding
y = 2, 3, 1, 6 ,5, 1, 5......
how do I pick the Y values that correspond to x = 1, 2, 3, 4 only
I have a few thousand points to search through and would appreciate some guidance.
thanks

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Sept. de 2015
If you have a list of desired x points and they are not integral then
ysubset = interp1(x, y, xsubset, 'nearest');
If you have R2015a or newer you could use
[tf, idx] = ismembertol(xsubset, x);
xfound = xsubset(tf);
ysubset = ysubset(idx(tf));
The interp1 and ismembertol techniques can also be used if your target x are integers. However, if your criteria is that you want to extract all of the values that correspond to integer x and leave out the others then,
tf = x == floor(x);
xsubset = x(tf);
ysubset = y(tf);

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by