if i==any elements in M
1 view (last 30 days)
Show older comments
Say I have a nX1 matrix M, i want to use condition, "if i==any elements in M", what should I type in Matlab?
0 Comments
Accepted Answer
Star Strider
on 19 Mar 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
0 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!