row location info from matrix
1 次查看(过去 30 天)
显示 更早的评论
I have 500*4 matrix and I want to find the row location where it holds the value I want. The problem is that there is some point that has the same value for different row. For example, my data would contain
.......
.......
.......
0.083821377996933 0.825816977489547 0.442678269775446 0.774910464711502 (139th)
0.228976968716819 0.538342435260057 0.106652770180584 0.817303220653433 (140th)
0.228976968716819 0.538342435260057 0.106652770180584 0.817303220653433 (141th)
.........
I want to get location of row where its 2nd component is in range of 0.53< 2ndComponent < 0.54,
3rd component is in range of 0.106< 3rdComponent <0.0107,
and minimum location value of number, so that it would come out to be 140 for this case.
0 个评论
回答(3 个)
Guillaume
2016-11-24
This is simply combining comparisons:
row = find(yourmatrix(:, 2) > 0.53 & yourmatrix(:, 2) < 0.54 & ...
yourmatrix(:, 3) > 0.106 & yourmatrix(:, 3) < 0.107, 1)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!