Skip to content

In this exercise you will approximate the value of definite integral of a function using both Riemann sums and a MATLAB built-in function integral. The code accepts as inputs: a function fun, a row vector n whose entries are the numbers of subintervals of partitions, and two scalars a, b, which are the endpoints of the interval of integration. R…

Notifications You must be signed in to change notification settings

abdullahmujahidali/stunning-tribble-MATLAB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

stunning-tribble-MATLAB

In this exercise you will approximate the value of definite integral of a function using both Riemann sums and a MATLAB built-in function integral. The code accepts as inputs: a function fun, a row vector n whose entries are the numbers of subintervals of partitions, and two scalars a, b, which are the endpoints of the interval of integration. Riemann sum calculations should be performed using partitions of [a,b] by subintervals of equal length h(j) defined as h(j)=(b-a)/n(j); where n(j)is a jth entry of n, with j=1:N and N=length(n). Each entry of the vector n, n(j), is the number of the subintervals of the corresponding partition of [a,b]. Your function has to return a table T whose first column formed by the entries of the vector n. Columns 2 – 4 are the column vectors c,d,f of the Riemann sums approximations of the integral of the function on the interval [a, b] by using the left endpoints (to calculate a vector c), the middle points (to calculate vector d), and the right endpoints (to calculate vector f) of each subinterval of the partition. The numbers of subintervals of the partitions are defined by the entries of n. **Write a function that begins with function [T,Int]=reimsum(fun,a,b,n) format compact N=length(n); that calculates vectors c, d, f as described above and forms a matrix A=[n',c,d,f]; The following command converts the N-by-4 array A into an N-by-4 table T with the names of the variables as indicated below. This command should be present in your code. T=array2table(A,... 'VariableNames',{'n','Left','Middle','Right'}) The output Int is definite integral of the function fun calculated by using a built-in MATLAB function integral.

About

In this exercise you will approximate the value of definite integral of a function using both Riemann sums and a MATLAB built-in function integral. The code accepts as inputs: a function fun, a row vector n whose entries are the numbers of subintervals of partitions, and two scalars a, b, which are the endpoints of the interval of integration. R…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages