📄 drawborders.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 M BM C1 C2
C1=[
0.5 0.4
% 0.4 0.50
% 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.20 % BUG emegent
0.90 0.43
%0.9 0.80
];%negative points
P=[C1;C2]; % all point of M3
M=cell(size(C1,1),1);
for i=1:size(M,1)
M{i}=cell(size(C2,1),1);
end
for i=1:size(C1,1)
for j=1:size(C2,1)
M{i}{j}=[C1(i,:),C2(j,:),1]; % 0 is flag to be canel
end
end
BM=cell(size(C1,1),1);
for i=1:size(BM,1)
BM{i}=cell(size(C2,1),1);
end
for i=1:size(C1,1)
for j=1:size(C2,1)
BM{i}{j}=[C1(i,:),C2(j,:),0]; % 0 is flag to be canel
end
end
SM=M;% save of M
SBM=BM;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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*');
%%%%%%%%%%%%%
%%% draw lines in M
X=0:0.1:1.0;
C=[ 'c', 'm', 'y', 'r', 'g', 'b', 'k', 'w'];
for i=1:size(M,1)
for j=1:size(M{1},1)
if(M{i}{j}(5)==1)
Y=perpendiF(i,j,X);% -(A(i,1)*X-b(i))/A(i,2);
c=C(mod(i,8)+1);
plot(X,Y,'linewidth',2,'color',c);
end
end
end
axis square
%colormap hot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M=SM;
IneqElim;%(P);
%%%%%%%%%%%%%
%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*');
M=BM
%%%%%%%%%%%%%
%%% draw lines in elim M
X=0:0.1:1.0;
C=[ 'c', 'm', 'y', 'r', 'g', 'b', 'k', 'w'];
for i=1:size(M,1)
for j=1:size(M{1},1)
if(M{i}{j}(5)==1)
Y=perpendiF(i,j,X);% -(A(i,1)*X-b(i))/A(i,2);
c=C(mod(i,8)+1);
plot(X,Y,'linewidth',2,'color',c);
end
end
end
%%%%%%%%%%%%%
axis square
%colormap hot
%celldisp(M)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
figure(3);
[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*');
%%%%%%%%%%%%%
%%% draw lines in elim M
X=0:0.1:1.0;
C=[ 'c', 'm', 'y', 'r', 'g', 'b', 'k', 'w'];
for i=1:size(M,1)
for j=1:size(M{1},1)
if(M{i}{j}(5)==1)
Y=perpendiF(i,j,X);% -(A(i,1)*X-b(i))/A(i,2);
c=C(mod(i,8)+1);
plot(X,Y,'linewidth',2,'color',c);
end
end
end
Z=G(0.2,0.3)
r=Ratio(BM)
%%%%%%%%%%%%%
axis square
%celldisp(M)
%colormap hot
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -