声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1159|回复: 9

[编程技巧] 新手求救 编程错误

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

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

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

x
程序是:
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(1:)=(t(1:)-min(t(1:)))/(max(t(1:))-min(t(1:)));
net=newlin(minmax(P),[5,14],{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
[net,tr]=train(net,P,T);
错误是:
??? Error: File: e:\MATLAB7\work\neural.m Line: 33 Column: 5
Unbalanced or misused parentheses or brackets.
好像是第33行的T的归一化有问题:
T(1:)=(t(1:)-min(t(1:)))/(max(t(1:))-min(t(1:)));
该怎么改呢?
回复
分享到:

使用道具 举报

发表于 2007-4-6 15:37 | 显示全部楼层
原帖由 spit 于 2007-4-6 14:27 发表
程序是:
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;
...


自己仔细检查括号配对或标点问题

[ 本帖最后由 eight 于 2007-4-6 17:13 编辑 ]
发表于 2007-4-6 15:55 | 显示全部楼层
LZ好象犯了低级错误,以及点运算要注意.我修改了一下,
不过ID取值可能有问题,这个就要你自己修改了.
%%%%%%%%%%%%%%%%%%%%%%%%%%
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(1,:)=(t(1,:)-min(t(1,:)))./(max(t(1,:))-min(t(1,:)));
net=newlin(minmax(P),[5,14],{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
[net,tr]=train(net,P,T);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 楼主| 发表于 2007-4-6 15:59 | 显示全部楼层

错误是

??? Error using ==> newlin
ID must be 0 for maximum learning rate to be calculated.

Error in ==> neural at 34
net=newlin(minmax(P),[5,14],{'tansig','purelin'},'traingdx');
怎么改?
发表于 2007-4-6 16:52 | 显示全部楼层
我觉得你应该自己多想想,试着自己解决问题,不要一有问题就马上问.
我将线性网络改为BP网络试了一下,余下你自己多想想吧:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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(1,:)=(t(1,:)-min(t(1,:)))./(max(t(1,:))-min(t(1,:)));
net=newff(minmax(P),[5,1],{'tansig','purelin'},'trainlm');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
[net,tr]=train(net,P,T);
%%%%%%%%%%%%%%%%%%%%%%%%%%%
发表于 2007-4-6 17:01 | 显示全部楼层
别急,学会调试,将会使你受益,否则这次别人告诉你了,下次又会碰到问题了。。
 楼主| 发表于 2007-4-6 20:17 | 显示全部楼层

谢谢

谢谢:lol
 楼主| 发表于 2007-4-24 10:01 | 显示全部楼层

对于上面的程序

在后面加上这几句
N15=input('test 15th N: ');
t15=input('test 15th T: ');
T15=(t15-min(p(2,:)))/(max(p(2,:))-min(p(2,:)));
test_mp=sim(net,[N15 T15]').*(max(t)-min(t))+min(t)
比如
第一次运行的输入T15=26.219
N15=0.7 得到73.05 第二次运行得79.13
希望在不关闭MATLAB的情况下 每次得到一样的结果
发表于 2007-4-24 10:05 | 显示全部楼层
原帖由 spit 于 2007-4-24 10:01 发表在后面加上这几句
N15=input('test 15th N: ');
t15=input('test 15th T: ');
T15=(t15-min(p(2,:)))/(max(p(2,:))-min(p(2,:)));
test_mp=sim(net,[N15 T15]').*(max(t)-min(t))+min(t)
比如
第一次运行 ...

请看帖子:神经网络matlab程序每次运行结果不同的一点看法

下次遇到问题请先搜索版面
 楼主| 发表于 2007-4-24 14:04 | 显示全部楼层

再次感谢

楼上大侠:handshake
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-11-14 05:42 , Processed in 0.065272 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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