How to determine the position of an integer
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a very basic question. I have a variable containing 5 numbers, say for eg,
d= [1 4 3 2 5]
how can i find the position of the number 3 in this d. I tried to use Find but I think I am using it wrong . Can anyone help me out please.
Thanks,
Vivekram
0 个评论
更多回答(2 个)
Jim O'Doherty
2013-5-9
Hi Vivekram,
I'd sugget using the "unique" command
[C, ia, ic]=unique(d)
ic will give you the indices of the numbers in your array d
Jim
Grzegorz Knor
2013-5-9
编辑:Grzegorz Knor
2013-5-9
If the values are in the cell format use cell2mat function:
pos = find(cell2mat(d)==3)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!