LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear Curve Fitting

Hi
 

I am trying to do a polynomial curve fitting on a set of data. It does not do the fitting correctly for some reason.

I was just wondering to see where the problem is.

 

Attachment is the program.

 

Thanks

0 Kudos
Message 1 of 42
(3,844 Views)

Try "Givens" instead of "SVD", seems to work alright.

The main problem is the fact that your x-values a gigantic and cover a very small range (the difference between xmin and xmax is less than 0.03%!!!) This causes poor conditioning. If you would rescale the data to a more normal range (e.g. as in the attached image), the fit will be much more robust. 🙂

 



Message Edited by altenbach on 03-01-2008 11:57 AM
0 Kudos
Message 2 of 42
(3,832 Views)


altenbach wrote:
This causes poor conditioning.

More specifically, you can setup the matrix for the polynomial fit and calculate the "Matrix condition number" with the tool from the "mathematics...linear algebra" palette.

Quote from the online help:
"The condition number of a matrix measures the sensitivity of a system solution of linear equations to errors in the data. It gives an indication of the accuracy of the results from a matrix inversion and a linear equation solution."

Using your X array and setting up the matrix for a second order polynomial gives the following results:

  • Your raw data: condition number=1.4272E+27 (extremely bad!!!!)
  • After subtracting the first element: condition number=1.8853E+12 (15 orders of magnitude better, but still horrible)
  • After adding the division: Condition number=19 (excellent!)


Message Edited by altenbach on 03-01-2008 12:47 PM
0 Kudos
Message 3 of 42
(3,820 Views)

Thank you for your reply.Smiley Happy

Do you know how I can do some operations on the values of the polynomial coefficients which are obtained from the fitting? For example I need to find (-a2/2*a1) which is equivalent to the value of resonant frequency that I am looking for.

Thanks

0 Kudos
Message 4 of 42
(3,799 Views)
Your fitting VI will provide you an array of parameters. Just use "index array" to extract the elements you want and do some math with them.
0 Kudos
Message 5 of 42
(3,784 Views)

Thanks

I could not found Logorithm function in the mathematics library, do you have any idea how I can take the logorithm of one of the element?

0 Kudos
Message 6 of 42
(3,762 Views)

I was wondering to see how I can calculate the amount of time that each part of VI takes to get complete,  for example I need to calculate the amount of time that the fitting function takes to do the fitting.

Which function does it?

0 Kudos
Message 7 of 42
(3,757 Views)

Hi

I found the function which does it.Smiley Happy

0 Kudos
Message 8 of 42
(3,744 Views)

Hi

I was wondering to see how I calculate the amount of time that each function takes to complete.

Do you know which function does it?

Thanks

 

0 Kudos
Message 9 of 42
(3,722 Views)


Maryam hosseini wrote:
I was wondering to see how I calculate the amount of time that each function takes to complete.
While there are many ways to do this, it is typically done with a 3-frame flat sequence. The code you want to measure goes in the middle frame and you take a tick count in the first and third frame. The difference between the two tick counts is the time in milliseconds for the middle frame.
 
(An example would be e.g. the first three frames of the following code: http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=305938#M305938)
 
Make sure that no other code can execute in parallel with the sequence to avoid incorrect results.
 
0 Kudos
Message 10 of 42
(3,705 Views)