matlab中出现?In an assignment A(I) = B,the number of elements in B and I must be the same.a = [1000,1327,1480,1489,1500,1536,1606,1700,1713,1725.01,1725.08,1732,1733,1747,1748,1750,1786,1789,1792,1811,1816,1833,1850,1854,1866,1893,1896,1904,1909,1

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 05:09:49
matlab中出现?In an assignment A(I) = B,the number of elements in B and I must be the same.a = [1000,1327,1480,1489,1500,1536,1606,1700,1713,1725.01,1725.08,1732,1733,1747,1748,1750,1786,1789,1792,1811,1816,1833,1850,1854,1866,1893,1896,1904,1909,1

matlab中出现?In an assignment A(I) = B,the number of elements in B and I must be the same.a = [1000,1327,1480,1489,1500,1536,1606,1700,1713,1725.01,1725.08,1732,1733,1747,1748,1750,1786,1789,1792,1811,1816,1833,1850,1854,1866,1893,1896,1904,1909,1
matlab中出现?In an assignment A(I) = B,the number of elements in B and I must be the same.
a = [1000,1327,1480,1489,1500,1536,1606,1700,1713,1725.01,1725.08,1732,1733,1747,1748,1750,1786,1789,1792,1811,1816,1833,1850,1854,1866,1893,1896,1904,1909,1923,1952,1955,1966,1967,1970,1973,1981,2010,2100];
b = [0,-24.834005,0.935502,0.002871,0.000738,0.057946,0.000125,0.018558,0.001109,0.000304,0.034329,0.000265,0.006013,0.001861,0.021482,0.000198,-30.946245,0.000651,0.001738,0.000815,0.004607,0.004689,-0.002675,0.005557,0.002959,0.022024,0.000638,0.00841,0.00027,0.006273,0.027772,0.063269,0.000694,0.000815,-0.000692,0.009561,0.003055,0.000084,0,96.243555];
c = 0;
for n = 1:38
    c = c+b(n);
    x(n)=a(n):0.01:2100;
    y(n)=b(40)/1000*x(n)+c;
    plot(x(n),y(n),'-r');
    hold on
end


完全没学过matlab,自己在网上搜索着写了这样一串代码,目的是想画出如图excel中的曲线,提示错误,

另外还试了一下这一段
for n = 1:38
c = c+b(n);
for x = a(n):0.01:a(n+1)
y=b(40)/1000*x+c;
end
plot(x,y,'-r');
hold on
end
结果只画出了点,没有连线.

matlab中出现?In an assignment A(I) = B,the number of elements in B and I must be the same.a = [1000,1327,1480,1489,1500,1536,1606,1700,1713,1725.01,1725.08,1732,1733,1747,1748,1750,1786,1789,1792,1811,1816,1833,1850,1854,1866,1893,1896,1904,1909,1
改成这样吧:
for n = 1:38
c = c+b(n);
x=a(n):0.01:2100;
y=b(40)/1000*x+c;
plot(x,y,'-r');
hold on
end