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

6 个评论

thank you! I have done it before but there was a problem, because I tried to find a non-exist number =)
found a solution yet?
go to the help of matlab.
go to the help of matlab.
ya i am also trying to check if a number appear in the array or matrix before anot.
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 Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by