p=[27.78 31.16 31.3 31.4 32.56 32.71 32.98 34.1 34.23 34.39 38.1 38.1 38.09 34.99 35.04 35.05 35.42 35.55 35.62 35.88 36.17 36.23 36.23 33.9 33.97 33.08 33.17;
26.14 29.46 29.57 29.71 30.86 30.83 31.32 31.94 31.29 31.7 35.29 35.47 35.31 32.31 32.09 32.17 33.02 32.89 33.33 32.75 33.36 33.13 32.8 31.11 29.95 30.34 30.04;
419.1 390.31 389.65 387.64 382.25 381.95 380.13 373.11 373.45 373.19 370.76 370.75 370.47 369.23 369.42 369.41 373.4 373.9 374.88 374.71 373.12 372.87 372.74 378.61 378.46 378.2 379.27;
396.26 348.69 345.94 349.68 336.68 339.86 345.6 334.26 339.34 334.15 332.31 327.28 335.23 328.58 324.32 323.95 327.64 330.15 328.97 328.16 332.09 333.46 328 351.85 352.31 362.99 361.09;
24.228 26.322 26.338 26.543 25.123 25.067 24.634 24.524 24.461 24.421 25.942 26.357 26.564 25.522 25.487 25.475 25.435 25.537 24.222 24.029 26.445 26.456 26.437 26.005 25.717 25.508 25.706;
29.519 34.512 35.329 34.87 37.197 36.606 34.152 37.11 36.841 37.697 41.124 42.147 41.452 41.948 39.715 39.913 40.739 40.435 39.471 40.169 40.899 40.178 39.627 33.795 35.809 33.159 33.442;
62.7 56.08 55.67 55.81 49.43 48.9 47.33 44.24 43.81 43.36 37.55 38.16 38.46 43.76 43.59 43.53 42.55 42.42 40.05 39.17 42.42 42.29 42.25 47.27 46.54 48.51 48.64;
76.4 73.53 74.67 73.32 73.19 71.41 65.61 66.94 65.98 66.93 59.53 61.02 60.02 71.93 67.92 68.21 68.15 67.17 65.26 65.48 65.6 64.23 63.33 61.43 64.81 63.06 63.28;
847 1323 1412 1246 1501 1480 1385 1465 1443 1378 1527 1622 1544 1670 1670 1652 1620 1632 1608 1603 1499 1469 1530 309 247 313 389;
951 1447 1535 1392 1680 1642 1504 1655 1518 1524 1638 1787 1641 1887 1876 1844 1812 1825 1736 1788 1617 1572 1696 936 934 438 453;
1.09 1.2 1.53 1.18 1.85 1.57 0.753 1.26 1.5 1.61 0.916 0.996 0.91 3.95 2.07 2.1 1.79 1.73 1.35 2.01 1.45 1.34 1.33 0.59 1.6 0.659 0.75;
359 286 291 292 286 288 271 278 296 286 262 253 270 299 277 277 276 279 266 279 278 279 266 281 320 326 322;
4.55 7.08 7.77 7.2 10.5 9.99 8.22 10.9 10.7 11.5 13.2 13.8 13 14.3 12.4 12.5 13.3 12.9 13.2 14 12.6 11.9 11.5 6.73 8.73 6.6 6.67;
0.54 0.781 0.728 0.807 0.868 0.917 1.28 1.16 1.02 1.04 1.76 1.71 1.73 0.8 0.955 0.959 1.12 1.11 1.33 1.1 1.2 1.21 1.17 1.28 0.79 1.14 1.04];
%训练目标向量t
t=[17.2 32.2 33.8 29.1 34.5 31.7 26 28.8 24.8 28.7 27.7 31.8 25 29.2 33.6 33.9 33.8 32.2 33.9 34.2 30 28.9 33.6 20 18.7 10.3 12.8];
%测试样本P_test
P_test=[27.97 32.83 35.13 35.73 33.11 27.56 35.65 34.16;
26.31 30.9 32.83 32.69 30.25 26.19 33.04 31.67;
417.59 381.6 369.59 375.17 378.25 420.53 374.42 378.51;
394.82 336.51 326.03 329.51 361.05 400.05 329.33 349.98;
24.111 25.11 25.49 24.114 25.559 24.301 25.611 25.534;
30.375 36.751 39.549 39.564 32.784 29.569 40.389 35.662;
61.74 48.66 43.36 39.64 48.52 63.73 42.3 45.73;
77.78 71.21 67.27 65.03 62.23 77.55 66.71 63.87;
814 1407 1640 1605 405 786 1625 1056;
932 1608 1886 1755 473 894 1809 1217;
1.61 1.58 1.45 1.76 0.605 1.07 1.6 0.847;
367 281 269 277 317 366 274 294;
5.39 10.1 12.2 13.4 6.23 4.53 12.9 8.76;
0.492 0.923 1.18 1.14 1.16 0.546 1.16 1.24];
%测试目标t1
t1=[16.9 34.2 32.4 33.7 12.1 15.3 33.4 20.7];
%训练样本归一化
[pn,minp,maxp,tn,mint,maxt] = premnmx(p,t);
%测试样本归一化
p2= tramnmx(P_test,minp,maxp);
%创建网络参数,可以根据自己要求修改
net=newff(minmax(pn),[14,1],{'tansig','tansig','purelin'},'traingdm');
net.trainparam.show=50;
net.trainparam.mc=0.9;
net.trainparam.lr=0.05;
net.trainparam.epochs=2000;
net.trainparam.goal=0.001;
%网络初始化
net=init(net);
%训练网络
[net,tr]=train(net,pn,tn);
%网络仿真
PN=sim(net,p2);
%反归一化
[t2]= postmnmx(PN,mint,maxt);
%mse指标
E = t1 - t2;
MSE=mse(E);
%作图表示实测值和仿真值
figure(1);
m=size(t2);
X=1:m(2);
plot(X,t2,'r*',X,t1,'bo');
title('o为真实值,*为预测值');
评论5