Integrating the following function using trapz method, while choosing a good step value (h = b-a/n ) to get enough accuracy and a fast result.
Show older comments

Hi guys,
So I am still a newbie at matlab, and I wrote this following code. But I am not sure on the step value I should pick for an accurate and fast result when integrating. Any help would be great, I have been tyring to figure it out for some time now. Thanks!
x = linspace(0,1,0.2);
y = (((sin(x)).^2)./x)-(x.*exp(2))-4;
z = trapz(x, y);
display(z)
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!