LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labwindows,how can i find the intersection of two curves?thanks.

Excuse me.Now I'm using Labwindows cvi 2013 s2,I want to find  the intersection of two curves.The curves come from polyfit .

err = PolyFit (x_values, CurrentValue, number_of_samples,polynomial_order, fitted_values1, coefs, &mse);
err = PolyFit (x_values, VoltageValue, number_of_samples,polynomial_order, fitted_values2, coefs, &mse);

x from 0,1,2,3...500

how can i get  the intersection of fitted_values1 and fitted_values2?

Thank you for answer.

0 Kudos
Message 1 of 4
(4,546 Views)

If 2 arrays have very close or exactly same y values for the same x value, that means they are intersecting.

 

I think you should subtract two arrays element by element from each other and look for values that are very close to zero.

 

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 4
(4,482 Views)

It depend on the required resolution you want.

 

A simple solution would be to find the 4 points involved in the intersection. Two points of each curve. You can find these four points by checking a point pair of each curve if they intersect (c1[i]<c2[i] && c2[i+1]<c1[i+1]). Careful this might just work in one quadrant.

If you need a better resolution you can find the solution of the 2 dimensional linear system. Each two points on the curves form a line. You can calculate the intersection of that line: http://en.wikipedia.org/wiki/Line_(geometry)

0 Kudos
Message 3 of 4
(4,435 Views)

Unless I'm mistaken, since you have the coefficients of the polynomials from the fitting function, you could subtract one of the polynomials from the other and use the root finding function CxPolyRootsEx() to find out where the roots are.  That would tell you the x coordinate(s) where they intersect each other. 

0 Kudos
Message 4 of 4
(4,384 Views)