www.pudn.com > AllNeuralNetworkCompute.rar > BP.m, change:2005-07-11,size:558b


clear all; 
close all; 
%-------------构造学习样本p,t------------% 
p=[-5:0.5:5]; 
PN=21; 
t=zeros(1,PN); 
for i=1:PN 
    x=pi*(-5+0.5*(i-1)); 
    if x==0; 
        x=0.001; 
    end 
    t(i)=sin(x)/x; 
end 
net=newff([-5,5],[10,1],{'tansig','purelin'},'traingda'); 
net=init(net); 
net.trainparam.show=50; 
net.trainparam.lr=0.1; 
net.trainparam.lr_inc=1.05; 
net.trainparam.epochs=500; 
net.trainparam.goal=1e-5; 
[net,tr]=train(net,p,t); 
a=sim(net,p); 
subplot(2,1,1); 
plot(p,t); 
xlabel('参考曲线'); 
subplot(2,1,2); 
plot(p,a); 
xlabel('逼近曲线');