Say I have a nX1 matrix M, i want to use condition, "if i==any elements in M", what should I type in Matlab?

 Akzeptierte Antwort

Star Strider
Star Strider am 19 Mär. 2015

0 Stimmen

You’re almost there!
Try this:
M = randi(100, 250, 1);
k = 42;
if any(M == k)
fprintf('\n\t\t\tEUREKA!\n')
end

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by