声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1013|回复: 3

[编程技巧] 最后几句输入输出怎么改?

[复制链接]
发表于 2007-4-12 16:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
下面程序最后输入T=0.7 N=23.204 希望能得到t中的第一个数据既:173 但是每次运行完
得到的与173相差甚远 有时还是负数 怎么改呢?
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]';
for i=1:2
P(i,:)=(p(i,:)-min(p(i,:)))/(max(p(i,:))-min(p(i,:)));
end
T=(t-min(t))/(max(t)-min(t));
net=newff(minmax(P),[5,1],{'tansig','purelin'},'trainlm');
%net=newff(minmax(P),[5,1],{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 800;
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(t))/(max(t)-min(t));
outmp=sim(net,[iN iT]').*(max(t)-min(t))+min(t)
end
特别是最后几句 我觉得不太对
回复
分享到:

使用道具 举报

 楼主| 发表于 2007-4-15 18:23 | 显示全部楼层

焦急等待中......

焦急等待中......
 楼主| 发表于 2007-4-16 09:13 | 显示全部楼层

自己改了

最后改完的程序:
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
大家看看 运行还不错
多谢大家帮助了
 楼主| 发表于 2007-4-16 09:14 | 显示全部楼层

有什么需要改进的 还请大家批评指正

有什么需要改进的 还请大家批评指正:handshake
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-24 15:24 , Processed in 0.061170 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表