Borrar filtros
Borrar filtros

How to return the rows with specific value?

3 visualizaciones (últimos 30 días)
Ahmed Hamed
Ahmed Hamed el 30 de Abr. de 2016
Respondida: Azzi Abdelmalek el 30 de Abr. de 2016
I have a simple matrix
X =
0 1 2
1 1 2
2 2.5 4.5
3 2 2
4 4 1.5
5 4 2.5
and another matrix
out = [3;4]
I'd like to return the rows in X whose rows start with any value in out
The output should look like
3 2 2
4 4 1.5
I tried this code
xx= X(X(:,1)==any(out),:)
but this always return the first row.
Any suggestion please Thanks in advance

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 30 de Abr. de 2016
Y=X(ismember(X(:,1),out),:)

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by