📄 p1.m
字号:
clc;clear;
p=[0.2 0.3 0.7 0.8;0.3 0.2 0.8 0.7]; %p为输入向量
t=[1.0 1.0 0 0]; %t为目标向量
plotpv(p,t); %绘制输入向量
net=newp([0 1;0 1],1); %建立一个单个神经元感知器
plotpv(p,t);
linehandle=plotpc(net.iw{1}, net.b{1}); %在原图上绘制分类线
e=1; %误差e为教师样本与实际输出的差
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;0.9];
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -