LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve Fitting

I am trying to use the non linear fit vi, and the fit is not even close. am I doing something wrong?  Two questions.

 

1. When using static VI reference, is it possible to input a path from the block diagram?

2. For curve fitting, is there a way to put a constrain on what the parameters estimates are?  For example, they can't be negative.

 

Thanks! 

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
Download All
0 Kudos
Message 1 of 9
(3,257 Views)

You need to be careful with the Levenberg-Marquardt algorithm. If your initial conditions are not close to the actual solution, it will not not minimize the error function. This is often true when there are multiple maxima and minima.

Message 2 of 9
(3,239 Views)

jyang72211 wrote:

1. When using static VI reference, is it possible to input a path from the block diagram?


If you want to change the model dynamically by file name, you need to simply open a VI reference in the old fashioned way (Same way we did before static VI references were available).

 

(I haven't looked at your code, have to attend a meeting.)

Message 3 of 9
(3,229 Views)

My quick test is to set the max iterations to 0 so the initial guess becomes the best fit and tweak the input parameters.   I usally stare at the formula (the x=0 point and the limiting values are good places to start) and estimate how the parameters effect the curve.  Then I try to find the order of magnitude for a starting guess.

 

My guess of {100,1,1,0,0.1,10} gives a decent looking curve, but I have no idea what the values should be.  C does go negative, I think it has to BTW otherwise there is a pole in your region which the data does not reflect.

 

Edit:  G does represent a lot of things quite well, math is not one of them.  Put a comment on your formula VI BD with the formula on it!

 

equation.png.png

Message 4 of 9
(3,220 Views)

I think the fitting would be more easy to follow if you would use log(current) as x (or simply use logarithmic mapping for the x-axis)

 

Still the curve looks like rather featureless banana and it is hard to imagine that you could get 6 uncorrelated parameters out of it. What is the error in the data?

 

Message 5 of 9
(3,197 Views)

In any case, the model seems to have way too many parameters, for example C vs. MPU and B vs. TM are 100% correlated, meaning a change in one can be fully compensated by a change in the other. This makes the fitting highly unstable, because there are millions of equally good solutions with widely varying parameters and the algorithm just wanders aimlessly around in the desert.

 

You need to tighten up the theory and e.g. treat some parameters as constants (e.g. fix at least one of each correlated pair for example).

 

Where does the data come from? What is the theory behind it?

 

Message 6 of 9
(3,186 Views)

Also, it seems that you started out with one of my old examples, but mutiliated it for no clear reason.

 

  • Why do you do a call by reference without providing inputs or outputs? Don't you want to calculate the guess plot here? (the middle plot is still called "guess"!)
  • Why do you re-calculate the best fit from the best fit paramters? The fitting VI already provides that output directly. (You only need to do that if you want to generate data with a wider or higher resolution x-ramp, for example.

Here's how it should look like instead.

 


Message 7 of 9
(3,181 Views)

The data is from a Time Current Curve (TCC) of a relay.  Time is the y-axis and current is the x-axis.  I know it sounds backwards, but not a typo.  It is what a switch uses to decide when to open when a given fault current is present.  

 

I think you are right, maybe some parameters are constant.  I will look into this.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 8 of 9
(3,136 Views)

I did use your old example.  I was playing with it in order to check it out, so I probably did things that had no clear reasoning behind it.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 9 of 9
(3,133 Views)