how to make ismember return a logical array

3 visualizaciones (últimos 30 días)
Milan Parsotam
Milan Parsotam el 6 de Sept. de 2018
Comentada: Guillaume el 6 de Sept. de 2018
Hi there
commonxvalues=ismember(xpoint,points);
commonyvalues=ismember(ypoint,points);
if ismember(commonxvalues,1)==0
points(counter,1)= xpoint;
end
if ismember(commonyvalues,1)==0
points(counter,2)= ypoint;
end
how do I make it so that common values returns a logical array. Otherwise, is there another function on matlab that will return a logical value if two elements in an array are the same, or a function that will return a logical value if ismember returns any positive output, because currently ismember returns a logical output in a 2d array. Cheers
  1 comentario
Guillaume
Guillaume el 6 de Sept. de 2018
Your question is not clear. ismember always return a logical array (as its first output), never anything else.
It would be better if you explained clearly what you're trying to achieve. That very odd construct
if ismember(commonxvalues, 1) == 0
could be written more clearly as
if ~commonxvalues
However, note that if commonxvalues is a vector or matrix, then it would be better off written as
if ~any(commonxvalues)
instead of using the often misunderstood behaviour of if when passed an array.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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