How to seperate the scattered population in three broad groups

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Pawel Jastrzebski
Pawel Jastrzebski am 9 Apr. 2018
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:

Weitere Antworten (1)

Razvan Carbunescu
Razvan Carbunescu am 9 Apr. 2018
Bearbeitet: Razvan Carbunescu am 9 Apr. 2018
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 Kommentar
Sanjib Banerjee
Sanjib Banerjee am 10 Apr. 2018
Thank you....much appreciated Razvan, I shall try with my dataset. Cheers. Sanjib

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by