LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

polynomial curve fitting and shifting goal posts

Hello,

 

I was wondering if there are tutorials in LabVIEW on how to modifiy polynomial coefficients if range end points have changed? I know how to fit a curve for points I acquire using DAQ and obtain the best fit coefficients. Is there Math anywhere you would know of on how to shift curve by adjusting coefficients if ENDPOINTS have changed? eg. my end points for a 4th order curve on range (1.5V, 0) (4.5V,13) has shifted to (2V, 0) (4.8V, 13). Any resources would be appreciated. THanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 1 of 16
(2,732 Views)

I don't quite uunderstand what you mean by "endpoint". Just redo the polynomial fit with the appropriate points replaced.

0 Kudos
Message 2 of 16
(2,728 Views)

Hi Altenbach,

 

By endpoints, I mean the two extreme points a.k.a range. If range changes, can I calculate new polynomial coefficients (a4,a3,a2,a1,a0) from old polynomial coefficients (a4_old, a3_old etc). I want to know if it is possible to compute this shift without acquiring many points within the new range and fitting for that model. (without redoing the fit)

 

Problem is that the shift in range is random and not linear or quadratic. THanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 3 of 16
(2,720 Views)

Sorry, I don't understand.

 

If it is the same data, the coefficients will stay the same, irrespective of the subrange you pick (under ideal conditions).

 

For a given set of polynomial coefficients, you can use "polynomial evaluation" to recalcuate the existing polynomial for an array of new x-values.

 

Can you attach an example program that show your old a new data so I can better understand. How many points do you have?

0 Kudos
Message 4 of 16
(2,715 Views)

Hi Altenbach,

 

I do a calibration process and obtain points, x and y (about 20 points). I define my range as the extreme points. (lowest and highest)

From these points, I fit a 4th order polynomial and obtain the coefficients. So I run my device using these coefficients to calculate the dependent variable (y) by measuring independent variable (x)

 

Problem I am having is that my range (on independent variable x) changes due to mechanical instabilities and design (which we can't overcome at the moment). So, I would have to do the calibration process again. Would I be able to obtain new coefficients (polynomial) by just measuring the lowest and highest point and not having to take the 20 points again.

 

eg. (x_low_old = 1.5V, y_low_old = 0)

      (x_high_old = 4.5V y_high_old = 13) and have 18 other points in between (x_1_old,y_1_old) (x_2_old,y_2_old) etc coefficients a4_old, a3_old, a2_old, a1_old, a0_old

 

If range changes to (x_low_new = 2V, y_low_new = 0) and (x_high_new=4.7V , y_high_new = 13) and not having in between 18 points, would I be able to calculate mathematically the shift to obtain a4_new, a3_new, a2_new, a1_new, a0_new.

 

Thanks! I will look for some actual data and send that if that would help better.

 

V

 

 

I may not be perfect, but I'm all I got!
0 Kudos
Message 5 of 16
(2,705 Views)

If you can assume that the old interval maps linearly into the new interval, then there is a solution. 

The idea is to compute the linear mapping from new interval into old interval, and use polynomial composition to generate new polynomial coefficients.

Look at the attached VI for details.  Diagram is commented. 

-Jim

0 Kudos
Message 6 of 16
(2,698 Views)

Thanks DSPGuy! My life would be a lot simpler if I could say there is a linear shift. unfortunately, I am faced with random shifts. But, assuming a linear shift could reduce my errors and also save me time.

 

Thing is my independent interval is the one that shifts. My dependent variable is the one that shifts. So, I am looking for the math to also understand how we can adjust from an already calculated fit to a new one. But, this vi will be a starting point.

 

** Can you post vi for LabVIEW v10? THanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 7 of 16
(2,696 Views)

It is straightforward to generalize the linear mapping idea to cover the Y values also.  As in the previous VI, first map the new X interval back to the old X interval, evaluate polynomial, then map old Y interval to new Y interval.  Attached is a modified (version 2010) VI that shows the mapping idea applied to both X and Y intervals.

 

-Jim

0 Kudos
Message 8 of 16
(2,690 Views)

Please note that this VI uses the fit polynomial from the old interval, and uses linear mapping to produce the polynomial coefficients that are equivalent to fitting the new X and Y values.  The only assumption is that the old X values (interval) is mapped to the new interval using a scale and offset, and that the old Y values are mapped to the new interval using a (different) scale and offset.

-Jim

0 Kudos
Message 9 of 16
(2,689 Views)

Thanks DSPGuy!! It is starting to make sense to me. Is there math that goes along with the vi? Most vis are from lib so there isnt much explanation on what the vi does. especially the polynomial ones. I can understand better if math equations are involved. Thanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 10 of 16
(2,632 Views)