How do I seperate datapoints in a plot?

1 回表示 (過去 30 日間)
Ruth van Heugten
Ruth van Heugten 2020 年 4 月 4 日
編集済み: Image Analyst 2020 年 4 月 5 日
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 件のコメント
Peng Li
Peng Li 2020 年 4 月 4 日
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 2020 年 4 月 5 日
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.

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

回答 (2 件)

Image Analyst
Image Analyst 2020 年 4 月 4 日
Try gscatter() instead.

Image Analyst
Image Analyst 2020 年 4 月 5 日
編集済み: Image Analyst 2020 年 4 月 5 日
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?

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by