I know rsum takes the middle riemann sum is there a way to find the left and right riemann sums both of which have a specified number of subintervals.

this is part of a school assignment and here is the part I need help with "calculate the left and right sums using the function between and using n subintervals."

1 Comment

Since this is a homework assignment, please show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

Answers (1)

x_to_probe = linspace(a, b, n+1);
function_at_left = f(x_to_probe(1:end-1));
function_at_right = f(x_to_probe(2:end));

1 Comment

rsums() has no direct way to specify the number of intervals. There is a slider underneath the rsums plot that allows you to manually adjust the number of intervals, but there is no easy application interface that would allow you to adjust that number. In theory you could write code that would interact with the slider to set the slider value to a particular number.
The relevant code inside rsums() that evaluates the integral for a given number of intervals is avaliable by examining the source code for rsums, and examining the plotrsums function implementation near line 100.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 27 Feb 2026

Commented:

on 27 Feb 2026

Community Treasure Hunt

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

Start Hunting!