作业帮 > 综合 > 作业

matlab的Vectors must be the same lengths.错误

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/04 03:29:40
matlab的Vectors must be the same lengths.错误
这个是我编写的一段程序,报了Vectors must be the same lengths错误,
>> t=0:0.01:10;
>> y=randn(size(t));
>> yn=sin(y);
>> p=y(1:30);
>> t=yn(1:30);
>> net=newff(minmax(p),[4,1],{'tansig','purelin'},'trainlm');
>> net.trainParam.show=10;
>> net.trainParam.epochs=1000;
>> net.trainParam.goal=0.001;
>> net.trainParam.lr=0.01;
>> [net,tr]=train(net,p,t);
>> figure(1);
>> plotperf(tr);
>> a=sim(net,p);
>> figure(2);
>> plot([0:0.01:29],t,'-+',[0:0.01:2.9],a,'-*');
最后一行 plot([0:0.01:29],t,'-+',[0:0.01:2.9],a,'-*');
一个是29 一个是2.9 ,或许是输入失误.
再问: 都改成29还是不对呀
再答: [0:0.01:29] 共2901个元素, a和t都只有30个元素,用plot命令时 2者不匹配。