📄 p3.m
字号:
clc;clear;
p=[-0.5 -0.3 -1 0.2 0.7 30;-0.8 0.1 0 -0.4 0.9 40];
t=[1 1 1 0 0 0];
plotpv(p,t);
net=newp([-1 30;-1 40],1,'hardlim','learnpn'); %建立范围[-1 30;-1 40]学习函数为learnpn的感知器
plotpv(p,t);
linehandle=plotpc(net.iw{1}, net.b{1});
e=1;net.adaptparam.passes=1;
net=init(net); %初始化感知器
linehandle=plotpc(net.iw{1}, net.b{1});
while(sse(e)) %修正感知器网络
[net,y,e]=adapt(net,p,t); %自适应网络
linehandle=plotpc(net.iw{1}, net.b{1},linehandle);
drawnow;
end;
P=[0.7;1.2];
a=sim(net,P); %对输入向量P进行仿真
plotpv(P,a)
thepoint=findobj(gca,'type','line');
set(thepoint,'color','red');
hold on; %在原图上继续作图,不覆盖原图像
plotpv(p,t)
plotpc(net.iw{1}, net.b{1}); %绘制分类线
hold off;
axis([-2 2 -2 2]); %定义坐标
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -