You can use the integral function in Matlab to compute definite integrals. To compute the definite integral of a function f between a and b, you can call the function as follows:
main.m16 chars2 lines
To calculate the area between the upper and the lower function and set it as i, you can define another function g as the difference between the upper and lower functions, and then pass g to the integral function. To ensure that the area is positive, you can use the abs function:
main.m91 chars5 lines
This will compute the area between the functions y = x and y = x^2 between x = 0 and x = 1, and store the result in i.
gistlibby LogSnag