row location info from matrix

1 view (last 30 days)
young jin Kwak
young jin Kwak on 24 Nov 2016
Answered: Guillaume on 24 Nov 2016
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.

Answers (3)

KSSV
KSSV on 24 Nov 2016
You can achieve your task with find. doc find.

Image Analyst
Image Analyst on 24 Nov 2016
Try ismembertol()

Guillaume
Guillaume on 24 Nov 2016
This is simply combining comparisons:
row = find(yourmatrix(:, 2) > 0.53 & yourmatrix(:, 2) < 0.54 & ...
yourmatrix(:, 3) > 0.106 & yourmatrix(:, 3) < 0.107, 1)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!