how to select desired row
2 views (last 30 days)
Show older comments
I have a 5 columns of data
data =
col1 col2 col3 col4 col5
1 3 0.9 0.02 94
2 4 01 0.05 93
3 1 2 0.03 94
1 3 5 0.236 97
4 5 10 0.059 69
2 10 02 0.02 89
now i want to select the values greater that 90 which is 5th column
and want to dispaly it for ex i want to dispay as
i have totally 900 rows and 5 column of data,please help
1 3 0.9 0.02 94
2 4 01 0.05 93
3 1 2 0.03 94
1 3 5 0.236 97
next i have two onws in column 1 i want to select the one corresponging to the value in column 5 which has greater value
the output must be
2 4 01 0.05 93
3 1 2 0.03 94
1 3 5 0.236 97
0 Comments
Accepted Answer
Sven
on 4 Nov 2011
A = [1 3 0.9 0.02 94
2 4 01 0.05 93
3 1 2 0.03 94
1 3 5 0.236 97
4 5 10 0.059 69
2 10 02 0.02 89 ]
% Get only those with col5 above 90
myMask = A(:,5)>90;
B = A(myMask,:)
% Sort everything by col5, descending
sortedB = sortrows(B,-5);
% Get the index of the first unique occurence in col1
[~,uniqueIdxs] = unique(sortedB(:,1));
% Get your final output
finalResult = sortedB(uniqueIdxs,:);
0 Comments
More Answers (1)
See Also
Categories
Find more on Database Toolbox 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!