Grouping data by value
3 ビュー (過去 30 日間)
古いコメントを表示
Hi. I have 432x1 data. I need to grouping the data.
for example;
-0.989088822111364
-1.16881053159657
-0.687960193675098
0.609028518151482
0.853112207247799
1.09867863373770
0.325581735572437
-0.358624505229866
-0.116184636997357
-1.12249570113502
-0.878711918410750
-0.843582079603111
-0.763107095944730
-0.963235098445007
-1.36135857090159
-1.93513836539865
-1.53179202986538
-1.24445835422832
0.643855927191538
0.506078478817649
1.10211477120999
0.119654919704736
-0.186087379373470
0.208608204079503
0.542441939121425
1.09907331469601
0.595582967612814
0.605674642059506
-0.0429774937224157
How can I assign them to groups such as:
moderate= -1.00 to -1.49
severe= -1.50 to -1.99
0 件のコメント
採用された回答
KSSV
2021 年 2 月 8 日
Let x be your data. Create arespective y-value which denotes grouping.
y = zeros(size(x)) ;
% get values -1.00 to -1.49
idx = x >= -1 && x < -1.49 ;
y(idx) = 1 ; % say one stand for moderate
% get values between -1.50 and -1.99
idx = x >= -1.50 && x < -1.99 ;
y(idx) = 2 ; % say two stand for
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2021 年 2 月 8 日
discretize() with boundaries and 'categorical' and a list of category names.
data = [
-0.989088822111364
-1.16881053159657
-0.687960193675098
0.609028518151482
0.853112207247799
1.09867863373770
0.325581735572437
-0.358624505229866
-0.116184636997357
-1.12249570113502
-0.878711918410750
-0.843582079603111
-0.763107095944730
-0.963235098445007
-1.36135857090159
-1.93513836539865
-1.53179202986538
-1.24445835422832
0.643855927191538
0.506078478817649
1.10211477120999
0.119654919704736
-0.186087379373470
0.208608204079503
0.542441939121425
1.09907331469601
0.595582967612814
0.605674642059506
-0.0429774937224157];
cats = discretize(data, [-1.99, -1.50, -1, 1, 1.5, 1.99], 'categorical', {'severe', 'moderate', 'nomimal', 'good', 'excellent'})
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Bar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!