LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get minima from curve fit array

I have data in a 2Xn array with voltage and position readings which I have put into a curve fit. Voltage follows a parabola and I wish to get the position at the min voltage. The position array is independent and voltage array dependent and fed into 'general polynomial fit.vi' with a 2nd order curve. Now the return array does happily follow a nice curve representing the voltage, but is 1-D and does not return 'x' values to represent my position. If I had this data I would simply get the min and then position and Im set. When I feed my data into the array I have a curve fit array which seems to ignore the actual positions I put in. These are of utmost importance. Any curve fitting experts? Your help is appreciated. Matt
0 Kudos
Message 1 of 2
(2,559 Views)
Hi Matt P,

the " general polynomial fit.vi" will also return an array of the coeficents. These are returned in assending order starting with the constant term.

The array you are plotting is the polynomial evaluated using the returned coeficients at the point you supplied. Or...

V = c + bx + ax^2

where
V= Voltage
X= Position

The extremes of V will occur where dV/dx=0.

Differetiating the above expression we get;

dV/dx = b + 2ax

Setting dV/dx equal to 0 and solving for x;

0 = b + 2ax

-b = 2ax

x = -(b/2a)

So the exteme occurs at -b/2a.

Use
the element at index "2" for a,
and
the element at index "1" for b

and you have your minimum.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 2
(2,559 Views)