MATLAB program- homework
Lab 10/Lab10.m
%{ Lab10.m Calculates the area below a curve using four differnt methods. This file should do four things: (1)Prompt the user to enter four items, a function to integrate (f), upper (b) and lower limits (a) of integration and the interval (n). (2)Pass data from the user into the four functions written below. (This is already done for you) (3)Displays results of left, right and middle Riemann sums and the trapezoidal method. (4)Plot the function given by the user. @author Kent Guerriero %} %Your code goes here %{ Calls the three functions used to calculate the Riemann sums and one used to calculate the Trapezoidal sum. Do not modify these four lines of code. %} left_Riemann=Left_Riemann(f,a,b,n); right_Riemann = Right_Riemann(f,a,b,n); middle_Riemann = Middle_Riemann(f,a,b,n); trapezoidal_Method = Trapezoidal_Method(f,a,b,n); %Your code goes here
__MACOSX/Lab 10/._Lab10.m
Lab 10/Left_Riemann.m
%{ Complete the function Left_Riemann to calculate the Riemann sum using left end points for the given function. Assign the value of the sum to the variable leftSum. @param f Function to find the area under. @param a The lower limit of integration. @param b The upper limit of integration @param n The interval used in the evaluation of the Riemann sum. @author Kent Guerriero %} function [ leftSum ] = Left_Riemann( f,a,b,n ) %Your code goes here end
__MACOSX/Lab 10/._Left_Riemann.m
Lab 10/Middle_Riemann.m
%{ Complete the function Middle_Riemann to calculate the Riemann sum using mid points. Assign the value of the sum to the variable middleSum. @param f Function to find the area under. @param a The lower limit of integration. @param b The upper limit of integration @param n The interval used in the evaluation of the Riemann sum. @author Kent Guerriero %} function [ middleSum ] = Middle_Riemann( f,a,b,n ) %Your code goes here end
__MACOSX/Lab 10/._Middle_Riemann.m
Lab 10/Right_Riemann.m
%{ Complete the function Right_Riemann to calculate the Riemann sum using right end points for the given function. Assign the value of the sum to the variable rightSum. @param f Function to find the area under. @param a The lower limit of integration. @param b The upper limit of integration @param n The interval used in the evaluation of the Riemann sum. @author Kent Guerriero %} function [ rightSum ] = Right_Riemann( f,a,b,n ) %Your code goes here end
__MACOSX/Lab 10/._Right_Riemann.m
Lab 10/Trapezoidal_Method.m
%{ Complete the function Trapezoidal_Method to calculate the area below the curve using trapezoids. Assign the value of the sum to the variable trapezoidalSum. @param f Function to find the area under. @param a The lower limit of integration. @param b The upper limit of integration @param n The interval used in the evaluation of the Trapezoidal sum. @author Kent Guerriero %} function [ trapezoidalSum ] = Trapezoidal_Method(f,a,b,n) %Your code goes here end