Riemann sum is a certain kind of approximation of an integral by a finite sum.
In this problem, I want you to use Midpoint Riemann sum to integrate a function.
As a test case, we should know that the integral of cos(x) over the interval [0,pi/2] is 1. Code numerical code, has only known spacing of the interval:
dx = pi/10;
x=0:dx:pi/2;
fx = cos(x([1:end-1])+dx/2)
riemannInt(fx,deltax)
ans =
1.004124203953987
Round the answer according to the test suite
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers21
Suggested Problems
-
How to find the position of an element in a vector without using the find function
2819 Solvers
-
Project Euler: Problem 8, Find largest product in a large string of numbers
1326 Solvers
-
Arrange vector in ascending order
822 Solvers
-
933 Solvers
-
110 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!