Cody

Problem 47583. Approximation of an integral - Riemann sum

Solution 3770843

Submitted on 22 Nov 2020 by David Hill
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
dx = pi/10; x = 0:dx:pi/2; fx = cos(x([1:end-1])+dx/2); y_correct = 1.004; assert(isequal(riemannInt(fx,dx),y_correct))

2   Pass
dx = 0.1; x = 0:dx:10; fx = 3*sin(x([1:end-1])+dx/2); y_correct = 5.52; assert(isequal(riemannInt(fx,dx),y_correct))

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!