How can I find a number in a matrix?

Hi, I want to find a number in a matrix. For example, I have an array x=1:10 and I want to find a number 4 in this array and get value of cell and row in matrix. How can I do this?

 採用された回答

Harshit
Harshit 2012 年 11 月 21 日

0 投票

6 件のコメント

Andrew
Andrew 2012 年 11 月 21 日
thank you! I have done it before but there was a problem, because I tried to find a non-exist number =)
VISHAL BARUN
VISHAL BARUN 2017 年 9 月 28 日
found a solution yet?
ANA ROSHAN
ANA ROSHAN 2020 年 2 月 13 日
go to the help of matlab.
ANA ROSHAN
ANA ROSHAN 2020 年 2 月 13 日
go to the help of matlab.
Soong Yuan See
Soong Yuan See 2020 年 2 月 25 日
ya i am also trying to check if a number appear in the array or matrix before anot.
Soong Yuan See
Soong Yuan See 2020 年 2 月 25 日
p = [11 10 2 1 5 7 4]
%check if the matrix contain number 5
contains5 = any(p(:) == 5)
if yes it will show 1 else 0
hope this is helpful

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

製品

質問済み:

2012 年 11 月 21 日

コメント済み:

2020 年 2 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by