How do I seperate datapoints in a plot?
1 view (last 30 days)
Show older comments
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
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.
Answers (2)
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?
0 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!