row location info from matrix

1 次查看(过去 30 天)
young jin Kwak
young jin Kwak 2016-11-24
回答: Guillaume 2016-11-24
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.

回答(3 个)

KSSV
KSSV 2016-11-24
You can achieve your task with find. doc find.

Image Analyst
Image Analyst 2016-11-24
Try ismembertol()

Guillaume
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)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by