From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Remien sum
Date: Sun, 22 Aug 2010 23:15:24 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 12
Message-ID: <i4sb2c$a7b$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1282518924 10475 (22 Aug 2010 23:15:24 GMT)
NNTP-Posting-Date: Sun, 22 Aug 2010 23:15:24 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2430764
Xref: comp.soft-sys.matlab:664131

Riemann Sum M-file: Write a function M-file for a function myriemann which takes four arguments f, a, b and n. You may assume that f is a continuous function on [a,b] and that a < b. Calculate and print the value of the left sum, right sum and midpoint sums of the function f on the interval [a,b] using n subintervals. Display the text: 
Left sum = ... 
Right sum = ... 
Midpoint sum = ... 

Suggested outline:
Initiate three variables L, R and M all to zero. These will contain your sums as you go.
Calculate the subinterval size.
Start a for loop.
Add the appropriate values to L, R and M by multiplying the interval width by the appropriate height and adding.
End the for loop.
Return 0.