I'm working on a project in Matlab
and need to find the area between two lines (intersecting in a point (xIntersection,yIntersection)
in the interval [-1,+1]. So the idea is to subtract the two lines and integrate between [-1, xIntersection] and [xIntersection, +1], sum the results and if it's negative, change its sign.
For details on how I find the intersection of the two lines check this link.
I'm using Matlab's
function int()
, here a snippet of my code:
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
doesn't return a real value for the integral but instead an expression containing a division, i.e. :
107813370750829368626584124420059/162259276829213363391578010288128
This prevents me from been able to do further operations with the result of integration.
- Any idea of why this is the returned value?
- Any idea of a possible loophole?