how i can draw full line in scatter plot?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609770/image.jpeg)
1 comentario
Scott MacKenzie
el 6 de Mayo de 2021
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".
Respuestas (0)
Ver también
Categorías
Más información sobre Define Shallow Neural Network Architectures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!