extract specific points from a matrix of planar coordinates

2 visualizaciones (últimos 30 días)
Tommaso Di Noto
Tommaso Di Noto el 1 de Mayo de 2017
Respondida: Tommaso Di Noto el 2 de Mayo de 2017
I have a 600x2 matrix with a series of planar points: x values on first column and y values on second one. How can I extract only the x values for which the corresponding y is null? Thank you!
  1 comentario
John Chilleri
John Chilleri el 1 de Mayo de 2017
Editada: John Chilleri el 1 de Mayo de 2017
What type of variable is your matrix (i.e. cell)? Or if it's a normal matrix, how do you define null?

Iniciar sesión para comentar.

Respuestas (2)

KSSV
KSSV el 1 de Mayo de 2017
Let A be your 600*2 matrix.
x = A(:,1) ;
y = A(:,2) ;
iwant = x(y==0) ; % respective _x_ for which y=0
  1 comentario
Tommaso Di Noto
Tommaso Di Noto el 2 de Mayo de 2017
Thank you! The passages are right; the only problem is that instead of 0 I have values such as 2e-04 or -4e-05. So if I write "==0" I get an empty vector. How can I solve this?

Iniciar sesión para comentar.


Tommaso Di Noto
Tommaso Di Noto el 2 de Mayo de 2017
I solved it; I just had to write:
iwant=x(y<0.001 & y>-0.001);
Thanks again!

Categorías

Más información sobre Matrices and 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!

Translated by