作业帮 > 英语 > 作业

? In an assignment A(I) = B, the number of elements in B and

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:英语作业 时间:2024/04/27 08:16:21
? In an assignment A(I) = B, the number of elements in B and I must be the same.
nmin=600,nmax=4000,m1=2000,m2=1800,m3=3880,r=0.367,gt=0.85,f=0.013,cda=2.77,io=5.83,Ifo=0.218,Iw1=1.798,Iw2=3.598,l=3.2,a=1.947,hg=0.9,ig1=5.56
ig=[5.56 2.769 1.644 1.00 0.793]
n=nmin:10:nmax
T=-19.313+295.27*(n/1000)-165.44*(n/1000).^2+40.874*(n/1000).^3-3.8445*(n/1000).^4;
for j=1:5
ft(j)=(T*ig(j)*io*gt)/r
ua(j)=(0.377*n*r)/(ig(j)*io)
end
plot(ua,ft)
? In an assignment A(I) = B, the number of elements in B and
In an assignment A(I) = B, the number of elements in B and I must be the same
中文解释:在赋值语句 A(I) = B 中,B 和 I 的元素个数必须相同
出错原因:I 和 B 的维数、大小不一样.这正如“把 5 个水果放到 6 个篮子”、或者“把 6 个水果放到 5 个篮子”,均无法实现
解决办法:自己设置断点调试一下,看看 I 和 B 的维数、大小是否相同,不同的话就要修改成两者一致
举例:
【错误代码】:
代码:
b = [1,2];
s(1) = b;
【正确代码】:
代码:
b = [1,2];
for i = 1:2
s(i) = b(i);
end
当然,这样的赋值使用循环是低效的,因此不提倡