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
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 Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!