新手求救 编程错误
程序是: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),,{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
=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:)));
该怎么改呢? 原帖由 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 编辑 ] 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),,{'tansig','purelin'},'traingdx');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
=train(net,P,T);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
错误是
??? Error using ==> newlinID must be 0 for maximum learning rate to be calculated.
Error in ==> neural at 34
net=newlin(minmax(P),,{'tansig','purelin'},'traingdx');
怎么改? 我觉得你应该自己多想想,试着自己解决问题,不要一有问题就马上问.
我将线性网络改为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),,{'tansig','purelin'},'trainlm');
net=init(net)
net.trainParam.epochs = 2000;
net.trainParam.goal = 0.001;
=train(net,P,T);
%%%%%%%%%%%%%%%%%%%%%%%%%%% 别急,学会调试,将会使你受益,否则这次别人告诉你了,下次又会碰到问题了。。
谢谢
谢谢:lol对于上面的程序
在后面加上这几句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,').*(max(t)-min(t))+min(t)
比如
第一次运行的输入T15=26.219
N15=0.7 得到73.05 第二次运行得79.13
希望在不关闭MATLAB的情况下 每次得到一样的结果 原帖由 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,').*(max(t)-min(t))+min(t)
比如
第一次运行 ...
请看帖子:神经网络matlab程序每次运行结果不同的一点看法
下次遇到问题请先搜索版面
再次感谢
楼上大侠:handshake
页:
[1]