how to select desired row

2 ビュー (過去 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 Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by