跪求大神解决MATLAB中Elman神经网络矩阵维度必须一致。 出错 tramnmx (line 80) pn = 2*(p-minp*oneQ)./((maxp-minp)*oneQ) - 1;

在这里插入代码片
```%输入数据  
P=[-0.406 -1.528 0.028;
0.486 0.032 0.351;
-0.615 1.059 -2.129;
0.066 0.342 0.438;
-1.784 -1.13 -0.123;
-2.469 2.559 0.158;
-0.559 -0.69 0.043;
2.659 0.467 -0.958;
-0.351 2.195 1.06;
-0.53 -0.876 -0.722;
0.603 0.085 0.568;
0.882 0.395 -1.954;
0.945 -1.483 1.394;
0.929 -0.815 0.004;
0.199 0.456 1.649;
1.347 -0.065 0.127;
-0.373 1.825 -0.083;
-0.408 -1.566 0.007;
-0.131 -0.292 -1.546;
0.801 -0.803 2.469;
0.974 0.699 -1.691;
-1.027 -1.461 0.238;
-1.227 -0.863 -2.131;
2.508 -1.113 -0.564;
1.003 0.677 -0.954;
-0.261 -0.473 0.415;
-0.488 -0.164 -0.309;
0.722 -0.356 -0.07;
-0.802 0.791 0.08;
-0.604 1.093 0.176;
0.388 0.537 -0.131;
-0.482 -0.355 0.368;
-0.564 -1.505 -0.335;
0.55 1.155 -0.696;
-0.768 -1.535 0.076;
-0.095 0.591 1.037;
0.367 -0.456 0.282;
1.356 1.521 -0.84;
0.395 1.233 -1.107;
0.453 0.065 0.313;
-1.34 1.196 -1.989;
-0.35 -1.227 -0.128;
0.9 0.689 1.661;
-0.811 -0.457 -0.749;
1.19 0.448 -1.864;
-0.266 0.009 0.506;
0.623 -1.496 -0.649;
-0.629 -1.033 -0.939;
-0.814 -0.511 0.367;
-0.215 1.095 -0.329;
0.672 1.09 -1.669;
0.453 0.065 0.313;
-1.255 0.322 0.799;
-0.349 -1.15 -0.091;
-0.965 -0.482 0.357;
0.541 0.843 2.308;
-0.177 0.577 -0.142;
-1.118 -1.034 -0.24;
-1.135 -1.1 -0.308;
-1.085 1.133 0.971;
0.984 0.145 0.609;
0.737 1.025 2.281;
-0.183 0.806 0.273;
0.668 -1.178 -0.403;
-0.658 -0.93 0.398;
-1.718 0.575 1.114;
-0.648 -0.703 0.523;
-0.564 2.04 0.691 ];  %训练数据
T=[35.4;
54.79;
53.9;
57.45;
27.25;
45.86;
45.1;
76.37;
46.22;
39.14;
52.01;
61.9;
42.99;
49.05;
60.14;
65.25;
67.7;
35.2;
44.2;
44.54;
75.5;
22.61;
22;
53.7;
70.3;
47.55;
38.41;
62.5;
43.43;
50.34;
58.5;
48.9;
28.63;
86.4;
22.61;
57.49;
55;
86.8;
51.4;
54.79;
45;
30.29;
54.5;
40.35;
61.77;
45.1;
38.81;
40;
31.62;
54.6;
64.25;
54;
36.99;
32.83;
33.96;
55.32;
42.81;
33.01;
31.61;
56.8;
52.15;
57;
40.5;
44.96;
35.2;
31.98;
35.21;
44.34
];%训练输出实际值
TestInput=[0.923 -0.108 -0.646;
-0.03 -0.508 1.203;
3.167 -0.495 0.909;
-0.237 0.105 -0.075];%测试数据
TestOutput=[64.6;
30.3;
74.57;
56.6;
]; %测试输出实际值
[pn,minp,maxp,tn,mint,maxt]=premnmx(P,T);
p2= tramnmx(TestInput,minp,maxp);
%创建Elman神经网络  
net_1 = newelm(minmax(pn),[3,1],{'tansig','purelin'},'traingdm');  
  
%设置训练参数  
net_1.trainParam.show = 20;  
net_1.trainParam.lr = 0.01;  
net_1.trainParam.mc = 0.9;  
net_1.trainParam.epochs =11000;  
net_1.trainParam.goal = 0.01;  
net=init(net_1);%初始化网络  
%训练网络  
net = train(net,pn,tn);  
%使用训练好的网络,自定义输入  
PN = sim(net,p2); 
TestResult= postmnmx(PN,mint,maxt);%仿真值反归一化
%理想输出与训练输出的结果进行比较  
E =TestOutput - TestResult 
%计算误差  
MSE=mse(E);%计算均方误差  
figure(1)
plot(TestOutput,'bo-');
hold on;
plot(TestResult,'r*--');
legend('真实值','预测值');
save('Elman.mat','net');


你可能感兴趣的:(跪求大神解决MATLAB中Elman神经网络矩阵维度必须一致。 出错 tramnmx (line 80) pn = 2*(p-minp*oneQ)./((maxp-minp)*oneQ) - 1;)