r*y
2 楼
最简单的就是composite trapezoid rule啊,用matlab一行搞定
integral = 0.5 * sum((y(1:end-1) + y(2:end)) .* diff(x))
上底加下底乘高除二,直观明了,管你x是不是equal spacing都适用.虽然
讲运算速度不是最优的,写起来最简单,也最便于检查。
I assume your values in x-vector is monotonically increasing
要是x equal spacing, 更简单了
dx = x(2)-x(1);
integral = (sum(y(2:end-1)) + 0.5 * y(1) + 0.5 * y(end) ) * h
【在 q***z 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: x 和 y 都已经是数值了,想算一个定积分的值。试了一下quad,这个用于函数的,用
: 不起来。不知道还有什么可以算,谢谢!
integral = 0.5 * sum((y(1:end-1) + y(2:end)) .* diff(x))
上底加下底乘高除二,直观明了,管你x是不是equal spacing都适用.虽然
讲运算速度不是最优的,写起来最简单,也最便于检查。
I assume your values in x-vector is monotonically increasing
要是x equal spacing, 更简单了
dx = x(2)-x(1);
integral = (sum(y(2:end-1)) + 0.5 * y(1) + 0.5 * y(end) ) * h
【在 q***z 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: x 和 y 都已经是数值了,想算一个定积分的值。试了一下quad,这个用于函数的,用
: 不起来。不知道还有什么可以算,谢谢!
相关阅读
how to set cutoff for sorting within unix systemOnline--ISI 2006 Impact Factor Computer Science Journals每天10个包子没有了请教:差异是否显著 (转载)请大家给看看问一个困扰多天的问题 (转载)Basic C++ Question, please .... for Managed C++IT and office supporting specialist有本科学医,后转学计算机的朋友吗?想请教一下请问怎么在windows下用SuperLU?快毕业的CS PhD看这里: SC07 to Feature 'Doctoral Showcase' AProtect cells' formatting求教一个Matlab fortran compiler 问题问一个matlab产生随机数的问题中大的数学学院下的信息计算科学专业怎么样?Call for Paper on Multi-aspect Analysis of Biological Pathways , San Jose, CA, USA Nov 2-4, 2007一个小问题请问有没有用过IMSL库的大虾?[合集] 请教c下面大数祖问题哪里能下载到Numerical Recipes?