How do I seperate datapoints in a plot?

1 view (last 30 days)
Ruth van Heugten
Ruth van Heugten on 4 Apr 2020
Edited: Image Analyst on 5 Apr 2020
Hello everybody,
I have a problems with solving something in Matlab. I have a random dataset S (which is given) which is a matrix of 600x3. I plotted that dataset with scatter3 in a threedimensional graph. Next to this, I have a line with the function y=0.7*x+0.5. You can see this all together in the picture. Now i want to seperate all the scattered point of S that are above the line y and plot all those points in red instead of in blue. How is it possible to do this?
Thanks in advance!
This is my script:
load(S)
figure(3)
scatter3(S(:,1),S(:,2),S(:,3)); % see above figure
xlabel('S_1')
ylabel('S_2')
zlabel('S_3')
axis('equal')
view(5,85)
hold on
x=-3:0.01:2.99;
y=0.7*x+0.5;
plot(x,y)
  2 Comments
Peng Li
Peng Li on 4 Apr 2020
How do you define “above line y” given this 3D problem? In terms of what? Z? Your line exists only in plane x-y; there aren’t any z values.
Ruth van Heugten
Ruth van Heugten on 5 Apr 2020
I define above line y in the x-y plane. So I want to get back all the coördinates (x,y and z coördinates) of the scattered points that are above line y if you look to the x-y plane. So the x,y and z coördinates of alle the scattered points that I circled.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 4 Apr 2020
Try gscatter() instead.

Image Analyst
Image Analyst on 5 Apr 2020
Edited: Image Analyst on 5 Apr 2020
Have you tried masking?
indexes = S(:, 2) > y;
S_AboveLine = S(indexes, :);
Attach your S data in a .mat file if you need more help.
Have you tried a clustering method like kmeans, svm, or dbscan?

Tags

Community Treasure Hunt

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

Start Hunting!