Using Trapz in matlab
이전 댓글 표시
Estimate the following integral using the trapz matlab function and b) the matlab function quad. Use n=2,4,8,16,32,64,128 and plot the difference bewtween the two methods as a function of n.
The function is as follows. sqrt(x)./(x+2)dx 1<=x<=3
So i am able to comfortable get the quad. However I can't seem to get a value for trapz. Here is what I have tried
First I made a for loop, Since I know that trapz operates on data not functions.
for k=1:7 y=2.^k end
However I'm not sure how to implement the for loop into solving the integral.
also how would I plot the difference bewtween the two methods as a function of n. I don't even understand what that means.
Thanks for the help
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!