MATLAB 用for循环给数组赋值的问题
要实现对x(1)到x(21)赋值,我代码如下:foru=0:0.05:1i=u*20+1;x(i)=x0+x1*power(u,2)+x2*power(u,3)+x3*p...
要实现对x(1)到x(21)赋值,我代码如下:
for u=0:0.05:1
i=u*20+1;
x(i)=x0+x1*power(u,2)+x2*power(u,3)+x3*power(u,3)+x4*power(u,4)+x5*power(u,5);
end
结果报错:
In an assignment A(I) = B, the number of elements in B and I must be the same.
X0、X1、X2、X3、X4、X5是普通的参数,请问我该如何修改? 展开
for u=0:0.05:1
i=u*20+1;
x(i)=x0+x1*power(u,2)+x2*power(u,3)+x3*power(u,3)+x4*power(u,4)+x5*power(u,5);
end
结果报错:
In an assignment A(I) = B, the number of elements in B and I must be the same.
X0、X1、X2、X3、X4、X5是普通的参数,请问我该如何修改? 展开
1个回答
推荐于2017-09-22
展开全部
x0=2;x1=2;x2=8;x3=3;x4=5;x5=4;%--------假设的值
for i=1:21
u=0:0.05:1;
x(i)=x0+x1*power(u(i),2)+x2*power(u(i),3)+x3*power(u(i),3)+x4*power(u(i),4)+x5*power(u(i),5);
end
for i=1:21
u=0:0.05:1;
x(i)=x0+x1*power(u(i),2)+x2*power(u(i),3)+x3*power(u(i),3)+x4*power(u(i),4)+x5*power(u(i),5);
end
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询