Sub indexing into cells

1 visualización (últimos 30 días)
Chameleon17
Chameleon17 el 7 de Oct. de 2015
Editada: Stephen23 el 7 de Oct. de 2015
Hello,
I am wondering if anyone can give me any pointers on a topic.
I have a logical vector of true false the same number of rows as my raw matrix.
The raw matrix, I would like to index for the rows that that are true in my logical vector.
The raw matrix is in cell format though and is a big mash of numerical and written data so I can't seem to convert it to another form.
Is there a way for me to pull the rows i'm interested in from this matrix?
Thanks for any help/advice/direction

Respuesta aceptada

Thorsten
Thorsten el 7 de Oct. de 2015
Xnew = X(ind, :);
  3 comentarios
Thorsten
Thorsten el 7 de Oct. de 2015
Editada: Thorsten el 7 de Oct. de 2015
If it is not logical you have to convert it to logical using
Xnew = X(logical(ind), :);
As help logical reveals,
Because logical arrays are returned by the logical operators (&,|,~)
and the relational operators (==,~=,<,<=,>=,>), as well as by
functions like ANY, ALL, ISNAN, ISINF, ISFINITE, ISEMPTY, ISEQUAL,
etc., it is unusual to need to invoke the logical function itself.
So presumably you have obtained your index by some other operations or did some numerical operation on it, (like minus), which caused Matlab to convert to double.
Chameleon17
Chameleon17 el 7 de Oct. de 2015
Ah! Yes, thank you, sigh, I should have noticed that.
Thank you! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion 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