I am working on a project in Matlab
and you need to find the area between two lines (intersecting at a point (xIntersection,yIntersection)
in the interval [-1, + 1]. So the idea is to subtract two lines and integrate between [- 1, xIntersection] and [xIntersection, +1], summarize the results and, if they are negative, change their sign.
For more information on how to find the intersection of two lines, check out this link.
I use Matlab's
int()
function, here is a code snippet:
xIntersection = ((x_1 * y_2 - y_1 * x_2) * (x_3 - x_4) - (x_1 - x_2) * (x_3 * y_4 - y_3 * x_4) ) / ((x_1 - x_2) * (y_3 - y_4) - (y_1 - y_2) * (x_3 - x_4)); syms x; integral = int( line 1 - line 2 expression containing x, x, -1, xIntersection) + int( line 1 - line 2 expression containing x, x, xIntersection, 1) if(integral < 0), integral = integral * -1; end
The problem is that Matlab
does not return a valid value for the integral, but instead an expression containing division, that is:
107813370750829368626584124420059/162259276829213363391578010288128
This does not allow me to perform further operations with the integration result.
- Any idea why this is a return value?
- Any idea of a possible loophole?
source share