Taking only the first element

72 次查看(过去 30 天)
Shehab Tarek
Shehab Tarek 2020-5-26
评论: Tommy 2020-5-26
I have matrix =[0,2 ;0,25 ;0,25;0,3] And I am using find function To get the index of every element The error occur when the search value is 0,25 it give an output [2,3] And I want to take only the first element of the output array Or the second element
  5 个评论
Tommy
Tommy 2020-5-26
To get only the nth index:
matrix = [0.2 ;0.25 ;0.25;0.3];
n = 2;
allIdx = find(matrix==0.25,n);
nIdx = allIdx(end);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by