how i can draw full line in scatter plot?

1 次查看(过去 30 天)
clear all
close all
clc
x1=[0.1 ,1.1;
6.8 ,7.1;
-3.5,-4.1;
2,2.7;
4.1 ,2.8;
3.1 ,5;
-0.8,-1.3;
0.9 ,1.2;
5 ,6.4;
3.9 ,4 ;
];
x2=[7.1 ,4.2;
-1.4 ,-4.3;
4.5 , 0;
6.3 , 1.6 ;
4.2 , 1.9 ;
1.4 , -3.2;
2.4 , -4 ;
2.5 , -6.1;
8.4 , 3.7 ;
4.1 , -2.2;
];
[m,n]=size(x1);
w=double(zeros(1,n+1));
w=double([0,0,0]);
w=perceptron(x1,x2,w,0.5);
scatter(x1(:,1),x1(:,2),'r');
hold on;
scatter(x2(:,1),x2(:,2),'g');
axis([-4 9 -6 10]);
line([0,-w(3)/w(1)],[-w(3)/w(2),0], 'Color', 'b');
  1 个评论
Scott MacKenzie
Scott MacKenzie 2021-5-6
I have no idea about the overall goal, but you can use lsline after each scatter function. You'll get a best-fitting line for each data set and it will be a "full line".

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by