Find highest third of values in dateset?

6 ビュー (過去 30 日間)
Peter Mills
Peter Mills 2018 年 1 月 12 日
編集済み: Star Strider 2018 年 1 月 12 日
WaveHeight=[3 1 5 2 3.1 6 5.5 3 2.5];
We need to find the highest 1/3:
HighestThird=[6 5.5 5]
But what if we what a function that will calculate the mean of the heights 1/3 of WaveHeight with the length of WaveHeight being a variable which may be large?
E.g.
WaveHeight=randi(1000,1,1000);
HighestThird=
  1 件のコメント
Adam
Adam 2018 年 1 月 12 日
編集済み: Adam 2018 年 1 月 12 日
"calculate the mean of the heights 1/3 of WaveHeight"
I don't understand what this means. What is it you want to take the mean of and what is it you want 1/3 of?
Since you are starting your own question here it makes sense to include your information here rather than reference a comment in another question with more information than this one. There is no guarantee that independent question (or the answer to which you replied) will not get deleted.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2018 年 1 月 12 日
編集済み: Star Strider 2018 年 1 月 12 日
One approach is to use the sort function:
WaveHeight=[3 1 5 2 3.1 6 5.5 3 2.5];
[Waves,Idx] = sort(WaveHeight, 'descend');
HighestThird = WaveHeight(Idx(1:fix(numel(Idx)/3)))
HighestThird =
6 5.5 5
also:
HighestThird = Waves(1:fix(numel(Idx)/3))
with the same result.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by