set the difference of the upper minus the lower function as i. use absolute value function to ensure positive area in matlab

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.m
integral(f,a,b)
16 chars
2 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.m
upper = @(x) x.^2;
lower = @(x) x;
g = @(x) abs(upper(x) - lower(x));
i = integral(g,0,1);
91 chars
5 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