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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

질문:

2015년 3월 19일

답변:

2015년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by