Borrar filtros
Borrar filtros

Find first row with certain value in x2 array

3 visualizaciones (últimos 30 días)
Gevin Schaeffer
Gevin Schaeffer el 7 de Jun. de 2021
Comentada: Gevin Schaeffer el 8 de Jun. de 2021
I have an 300x2 array in which I need to find a certain numbert in colum 1, e.g. 10. Once the number is found I need to extract the corresponding value in colum 2.

Respuesta aceptada

Chunru
Chunru el 8 de Jun. de 2021
idx = A(:, 1) == 10; % find the index that 1st column = 10
b = A(idx, 2); % extract the corresponding data in 2nd column
Or in one line
b = A(A(:,1)==10, 2);
  1 comentario
Gevin Schaeffer
Gevin Schaeffer el 8 de Jun. de 2021
Thanks :) ! it is really that simple. I literally just started with MATLAB

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by