How to write an automatic function based on the median of data to form groups of data.
1 回表示 (過去 30 日間)
古いコメントを表示
How to write an automatic function based on the median of data to form groups of data.
as the boxplots are here in this figure, i need to make groups or clusters of data based on median. like once i have median of data, then i need to identify the beginning of a new cluster/group when the median delay increase instead of decresing. and when the median again increases then from that point a new group or cluster will start.
i manually grouped the data based on median, i need to make function like this.
Thanks in advance.
0 件のコメント
採用された回答
Adam Danz
2021 年 6 月 21 日
編集済み: Adam Danz
2021 年 6 月 21 日
% Create demo data : nxm matrix with 1 box per column
rng('default')
data = rand(100,15) + [1.0 1.3 0.8 0.95 1.02 1.05 1.08 1.2 1.0 1.03 1.06 0.90 0.95 0.80 1.1];
% Compute median of each column
dataMedians = median(data);
% Create boxplot
h = boxplot(data);
% Add group separation lines
groupStart = diff([inf,dataMedians])<0;
groupIdx = find(groupStart);
for i = 1:numel(groupIdx)
xline(groupIdx(i)-.5, 'k--', 'LineWidth',1)
end
% Color the groups
colors = lines(sum(groupStart));
groupID = cumsum(groupStart);
for i = 1:sum(groupStart)
set(h(:,groupID==i), 'Color', colors(i,:))
end
% Create demo data : nxm matrix with 1 box per column
rng('default')
data = rand(100,15) + [1.0 1.3 0.8 0.95 1.02 1.05 1.08 1.2 1.0 1.03 1.06 0.90 0.95 0.80 1.1];
% Compute median of each column
dataMedians = median(data);
% Create boxplot
figure()
h = boxchart(data);
% Add group separation lines
groupStart = diff([inf,dataMedians])<0;
groupIdx = find(groupStart);
for i = 1:numel(groupIdx)
xline(groupIdx(i)-.5, 'k--', 'LineWidth',1)
end
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!