最后改完的程序:
p=[0.7 23.204;
0.533 23.911;
0.7 24.024;
0.533 28.003;
0.533 29.901;
0.7 25.488;
0.533 25.472;
0.4 19.569;
0.4 24.087;
0.7 27.297;
0.533 33.793;
0.533 36.363;
0.533 30.672;
0.533 32.189;]';
t=[173;
157.5;
178.5 ;
126;
181.5;
150;
149;
143.5;
169;
174.5;
149;
119;
107;
123]';
P(2,:)=(p(2,:)-min(p(2,:)))/(max(p(2,:))-min(p(2,:)));
T=(t-min(t))/(max(t)-min(t));
net=newff(minmax(P),[7,1],{'tansig','purelin'},'trainlm');
%net=newff(minmax(P),[5,1],{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 600;
net.trainParam.goal = 0.001;
[net,tr]=train(net,P,T);
mmin=[172 156 178 124 178 148 148 142 168 174 148 118 105 120];
mmax=[174 159 179 128 185 152 150 145 170 175 150 120 109 126];
format bank;
mp=sim(net,P).*(max(t)-min(t))+min(t)
no=[1 2 3 4 5 6 7 8 9 10 11 12 13 14];
figure;
plot(no,mmin,'ro',no,mp,'*',no,mmax,'ro');
choose=input('Do you want to test 4 groups of data,input "1" to go on or"0" to stop.');
if (choose==0),break;
else
iN=input('N: ');
it=input('T: ');
iT=(it-min(p(2,:)))/(max(p(2,:))-min(p(2,:)));
outmp=sim(net,[iN iT]').*(max(t)-min(t))+min(t)
end
大家看看 运行还不错
多谢大家帮助了 |