필터 지우기
필터 지우기

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