Logical index multiple columns
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rainer Danner
el 17 de Dic. de 2019
Editada: Ridwan Alam
el 17 de Dic. de 2019
We have a 111x1402 array A with one or no logical true for each column.
E.g.:
0 0 1 0 ...
1 0 0 0
0 1 0 1
.
.
.
Now we want to get the values for each of the 1402 columns from another array B which is 111x2.
Meaning the row of the 111 where there is a logical true in array A.
E.g.:
500 142
450 -12
305 125
. .
. .
. .
How can we achieve this in Matlab?
3 comentarios
Adam Danz
el 17 de Dic. de 2019
You lost me at , "Now we want to get the values for each of the 1402 columns from another array B which is 111x2." Does array B have 2 or 1402 columns? By "get the values" do you mean the row number of the 1-and-only TRUE in each column?
Rainer Danner
el 17 de Dic. de 2019
Editada: Rainer Danner
el 17 de Dic. de 2019
Respuesta aceptada
Ridwan Alam
el 17 de Dic. de 2019
Editada: Ridwan Alam
el 17 de Dic. de 2019
I believe you are trying to find the row-indices of A, where the row contains a 1, and then extract those rows from B. In that case, this should help:
B(any(A,2),:)
0 comentarios
Más respuestas (0)
Ver también
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!