if i==any elements in M

1 次查看(过去 30 天)
Say I have a nX1 matrix M, i want to use condition, "if i==any elements in M", what should I type in Matlab?

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by