performing integration using quadgk
6 次查看(过去 30 天)
显示 更早的评论
I would like to perform integration of y w.r.to x wherein I know the limits a, b (lower and upper limits for x) as well as the arrays x and y (n x 1 size each) using quadgk.
For example, see the below code:
x=0.0:0.1:5;
y=exp(x);
int_exact = exp(5) - exp(0);
int_trapz = trapz(x,y);
int_quadgk = quadgk(@integrand,0,5);
How can I code to get int_quadgk using the x and y arrays ONLY and NOT the function exp(x)? That is, I know only x and y arrays and NOT the function from which they were arrived at.
Please help.
Thanks
0 个评论
回答(1 个)
Walter Roberson
2013-11-19
quadgk is strictly for the case where you can pass in a function. trapz() is suitable for numeric integration over a fixed set of data.
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!