Hello everyone !
In the following 577X2 matrix I have tickers of stocks in the first column and the number of occurence in the second one.
How would I keep the 80 first stocks (tickers) that occurred the most ?
Many thanks in advance !
Pierre

 채택된 답변

Guillaume
Guillaume 2017년 5월 23일
편집: Guillaume 2017년 5월 23일

1 개 추천

[~, order] = sort(Occurences.Momentum(:, 2), 'descend');
top80 = Occurences.Momentum(order(1:80), :)
Or:
sortedData = sortrows(Occurences.Momentum, 2, 'descend');
top80 = sortedData(1:80, :)

추가 답변 (1개)

KSSV
KSSV 2017년 5월 23일
편집: KSSV 2017년 5월 23일

0 개 추천

Let data be you 577X2 data.
[val,idx] = sort(data(:,2),'descend') ; % sort the second column in descending order
iwant = data(idx(1:80),:) ; % pick first 80 most occurring stocks

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

질문:

2017년 5월 23일

편집:

2017년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by