MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何用for循环的答案填充零向量? (https://www.labfans.com/bbs/showthread.php?t=22238)

poster 2019-11-28 17:20

如何用for循环的答案填充零向量?
 
我创建了一个零向量,名为

result = zeros(1,20); 在GNU Octave GUI上,我想用for循环的积分估计值填充零。

a = 0; b = 3; f = @(x) sin(10 *x.^2); for i = 20 n = 2.^i; dx = (b - a) / n; left = a:dx: (b - dx); right = (a+dx) :dx:b; h1 = f(left); h2 = f(right); areas = (h1 + h2) ./ 2 .* dx; totalarea = sum(areas) endfor 谁能告诉我如何用上面的for循环中的totalarea值填充result矩阵?



[url=https://stackoverflow.com/q/59075373]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 21:30

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.