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 ExchangeGet 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