how to select desired row

1 次查看(过去 30 天)
FIR
FIR 2011-11-4
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

采纳的回答

Sven
Sven 2011-11-4
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,:);

更多回答(1 个)

Srinivas
Srinivas 2011-11-4
help sortrows

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by