How to seperate the scattered population in three broad groups

1 回表示 (過去 30 日間)
Sanjib Banerjee
Sanjib Banerjee 2018 年 4 月 9 日
コメント済み: Sanjib Banerjee 2018 年 4 月 10 日
I would appreciate your help and suggestions. Please find attached the XY plot where the (X,Y) points are broadly separated in three regions ( marked) based on some geochemical anomaly.For any set of data, I can manually separate these three regions 1) High X values with high scatter on the top (High SD) followed by 2) middle region with moderate X values less scatter (SD low) 3) Very low X values , uniform with less scatter ( very low SD). How to separated these three regions by using Matlab and put the marker lines as marked with dashed line? Regards, Sanjib

採用された回答

Pawel Jastrzebski
Pawel Jastrzebski 2018 年 4 月 9 日
If you want to manually decide where the partition line is, then this is more or less how you would go about recreating your Excel chart in Matlab, obviously using real data:
% Randomly generated data
x = 1:30;
y = 0.5*x;
y(1:10) = y(1:10).*rand(1,10);
y(11:20) = y(11:20)+4*rand(1,10);
y(21:30) = y(21:30)+8*rand(1,10);
% partition lines data
x1 = [min(x) max(x)]; % x-range for the partition lines
y1 = [4 4]; % dashed black line
y2 = [15 15]; % dashed red line
% main plot
figure
p(1) = plot(x,y);
hold on
p(2) = plot(x1,y1);
p(3) = plot(x1,y2);
title('Chart title')
xlabel('x-axis data')
ylabel('y-axis data')
legend({'Main data' 'partition A' 'partition B'},...
'Location','best')
% set the properties of the lines
% p(1) - main data
set(p(1),...
'LineStyle' ,'-',...
'LineWidth' ,0.5,...
'Color' , [0 0 0],...
'Marker' , '.',...
'MarkerSize' , 12,...
'MarkerFaceColor',[0 0 1],...
'MarkerEdgeColor',[0 0 1]);
% p(2) and p(3) - partition lines COMMON settigs
set([p(2), p(3)],...
'LineStyle','--',...
'LineWidth',0.5);
% p(2) - color
set(p(2),...
'Color', [0 0 0]);
set(p(3),...
'Color', [1 0 0]);
The output:

その他の回答 (1 件)

Razvan Carbunescu
Razvan Carbunescu 2018 年 4 月 9 日
編集済み: Razvan Carbunescu 2018 年 4 月 9 日
In addition to the suggestion above, if you are looking for a way to automate the process of splitting the data could look at the ischange functionality added in R2018a.
% Code to find change locations
[TF,S1] = ischange(y,'MaxNumChanges',2);
plot(y,'*'); hold on; stairs(S1);
For your particular dataset it seems like a variance approach might work best to separate the 3 domains.
  1 件のコメント
Sanjib Banerjee
Sanjib Banerjee 2018 年 4 月 10 日
Thank you....much appreciated Razvan, I shall try with my dataset. Cheers. Sanjib

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

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by