📄 drawborders2.m
字号:
%function [A,b]=getBorders(C1,C2)
%[A,b]getBorders get border functions of C1 and C2 in form of output [A,b]
clc
clear all
global C1 C2
C1=[
0.4 0.45
0.5 0.40
0.5 0.75
0.65 0.15
0.18 0.62
]; % positive points
C2=[0.1 0.6
0.15 0.41
0.25 0.8
0.30 0.61
0.80 0.76
%0.9 0.29 % BUG emegent
%0.90 0.40
0.91 0.10
];%negative points
T1=[0.4 0.53
0.4 0.51
0.5 0.41
0.5 0.71
0.65 0.13
];
T2=[0.1 0.4
0.15 0.43
0.25 0.5
0.30 0.2
0.8 0.73
0.9 0.41
];
[A,b]=getBorders(C1,C2);
figure(1);
[X,Y] = meshgrid(0:0.005:1.0);
Z=G(X,Y);
contourf(X,Y,Z)
hold on
plot(C1(:,1),C1(:,2),'bs');
plot(C2(:,1),C2(:,2),'y*');
B=[A,-b,zeros(size(A,1),1)]; %borders with flag 0 initially;
P=[C1;C2]; % all point of M3
%%%%%%%%%%%%%
X=0:0.1:1.0;
C=[ 'c', 'm', 'y', 'r', 'g', 'b', 'k', 'w'];
for i=1:size(A,1)
Y=-(A(i,1)*X-b(i))/A(i,2);
c=C(mod(i,8)+1);
plot(X,Y,'linewidth',2,'color',c);
end
%axis([0,1.5,0,1.5]);
axis square
%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:size(P,1)
for j=1:size(B,1)
if( linearM3(P(i,1),P(i,2))== linearDist(P(i,:),B(j,:)) ) % if M3 output = linearDist
B(j,4)=1; % 1 will not be elim
end
end
end
B
B(find(B(:,4)==0),:)=[];
B
figure(2);
[X,Y] = meshgrid(0:0.005:1.0);
Z=G(X,Y);
contourf(X,Y,Z)
hold on
plot(C1(:,1),C1(:,2),'bs');
plot(C2(:,1),C2(:,2),'y*');
%plot(T1(:,1),T1(:,2),'bs');
%plot(T2(:,1),T2(:,2),'y*');
[D,d]=IneqElim2(A,b);
D=B(:,1:2)
d=-B(:,3)
%%%%%%%%%%%
X=0:0.1:1.0;
C=[ 'c', 'm', 'y', 'r', 'g', 'b', 'w', 'k'];
for i=1:size(D,1)
Y=-(D(i,1)*X-d(i))/D(i,2);
c=C(mod(i,8)+1);
plot(X,Y,'linewidth',2,'color',c);
end
%axis([0,1.5,0,1.5]);
axis square
%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -