matlab中带有下标的复制维度不匹配怎么解决谢谢各位大神帮助,小白真的不懂求解谢谢!!
a = 1.0e+03 * 0.0375 0.7606 1.5795 0.0103 0.3264 1.9289 0.0291 0.4591 1.8943 0.0738 0.6936 1.6746 0.0408 0.4081 1.6849 0.0258 0.4350 1.6344 0.0812 0.6748 1.5973 0.0316 0.3681 2.1708 0.0189 0.3705 1.7276 0.0106 0.5245 1.8910 0.0186 0.4171 1.7259 0.0284 0.5074 1.8326 0.0140 0.4600 1.7825 0.0162 0.3040 1.9991 0.0105 0.4872 2.0013 0.0396 0.6385 1.8687 0.0241 0.3564 2.0845 0.0376 0.3969 1.9968 0.0077 0.2865 2.0966 0.0284 0.5720 2.0604 0.0275 0.5855 1.9309 0.0182 0.3179 2.0995 0.0196 0.3456 1.8670 0.0271 0.4869 1.8856 0.0078 0.4259 1.9799 0.0068 0.3859 1.9006 0.0247 0.4458 1.8364 0.0247 0.4559 1.8303 0.0086 0.3199 1.7712 0.0257 0.6681 1.5887 0.0273 0.5359 1.5213 0.0355 0.5437 1.5644 0.0502 0.4156 1.4656 0.0201 0.5266 1.5297 0.0590 0.6822 1.3755 0.0173 0.4589 1.5790 0.0471 0.7243 1.5430 0.0348 0.5964 1.5220 0.0145 0.2907 1.6196 0.0430 0.6183 1.5388 0.0361 0.4635 1.5756 0.0190 0.3344 1.5516 0.0195 0.4059 1.4399 0.0070 0.2183 1.6277 0.0986 0.7534 1.3643 0.0081 0.2673 1.4056 0.0046 0.2267 1.5144 0.0039 0.1841 1.6528 0.0032 0.3033 1.4433 0.0097 0.5191 1.2604 0.0046 0.2683 1.3966 0.0211 0.5616 1.1247 0.0122 0.4756 1.2460 0.0052 0.3235 1.2397 0.0089 0.4569 1.1217 0.0072 0.3845 1.0723 0.0094 0.5211 0.9348
>> for i=1:52
p(i,:)=[a(i,:),a(i+1,:),a(i+2,:),a(i+3,:),a(i+4,:)];end p_train=p(1:42,:);
t_train=a(6:47,:);
p_test=p(43:52,:);
t_test=a(48:57,:);
p_train=p_train';
t_train=t_train';
p_test=p_test';
nn=[5 6 7 8 9 10 11 12 13];
for i=1:9
threshold=[0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1;0 1];
net=newelm(threshold,[nn(i),3],{'tansig','purelin'});
net.trainparam.epochs=1000;
net.trainparam.show=20;
net=init(net);
net=train(net,p_train,t_train);y=sim(net,p_test);
error(i,:)=y'-t_test;
end
警告: NEWELM used in an obsolete way. > In nnerr.obs_use (line 17) In newelm>create_network (line 128) In newelm (line 103) See help for NEWELM to update calls to the new argument list. 带有下标的赋值维度不匹配。
存在问题:
第一行对x赋值为列向量,而在第三行又对x进行转置并赋值给A的第一列,所以会出错。
改正(两种方法选其一,不可同时改):
1、把第一行改成:
1x=0:0.25:2.25;其余不变。
2、把第3、4行改成:
12A(:,1)=x;A(:,2)=x.^2其余不变。
另外,如果A在工作区中已有定义,并且行数与x长度不匹配,也会导致错误。建议把第三行改成
1A=x;就不会有问题了。或者,另一种做法是在代码前面加上一句
1clear A