フィルターのクリア

Categorizing array elements based on percentage

3 ビュー (過去 30 日間)
KK14
KK14 2020 年 6 月 25 日
コメント済み: KK14 2020 年 6 月 26 日
I have an array, whose odd indices are to be divided into 4 categories based on some predefined percentage.For example, say X = [1,2.....20],odd_ind = [1 3 5...17 19], among which the first 40% are to be categorized as 1, next 30% as 2, next 20% as 3 and next 10% as 4.Could anyone guide me through this?I am a beginner and need some help with this.
Thanks in advance.
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 6 月 26 日
Is that first 40% and so on by value, or by index?
KK14
KK14 2020 年 6 月 26 日
index

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

採用された回答

Rasul Khan
Rasul Khan 2020 年 6 月 26 日
You can have the four categories separated this way.
a = 1 : 20;
odd_ind = a(1 : 2 : end);
category1 = odd_ind( (1 : end) <= 0.4 * end );
category2 = odd_ind((1:end) > 0.4 * end & (1 : end) <= 0.7 * end );
category3 = odd_ind((1:end) > 0.7 * end & (1 : end) <= 0.9 * end );
category4 = odd_ind((1:end) > 0.9 * end );
  1 件のコメント
KK14
KK14 2020 年 6 月 26 日
Thankyou.It worked just fine for me!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by