if i==any elements in M

1 visualización (últimos 30 días)
Patrick
Patrick el 19 de Mzo. de 2015
Respondida: Star Strider el 19 de Mzo. de 2015
Say I have a nX1 matrix M, i want to use condition, "if i==any elements in M", what should I type in Matlab?

Respuesta aceptada

Star Strider
Star Strider el 19 de Mzo. de 2015
You’re almost there!
Try this:
M = randi(100, 250, 1);
k = 42;
if any(M == k)
fprintf('\n\t\t\tEUREKA!\n')
end

Más respuestas (0)

Categorías

Más información sobre Logical 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