LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nonlinear optimization help

I need to write a program that can fit parameters to a model function from data using nonlinear optimization. I've struggled to get the parameters in the model to converge on a solution that fit the data. I now believe my implementation of the LabVIEW code is the problem not my model function. So I attempted to find a solution to a very simple function cos(c1*x), where c0=0.1, see attached VIs. Even this simple function will not converge on my data. I'd appreciate it if someone who has experience using numerical methods in LabVIEW if they would please look over my code and report my error. Thanks.
Message Edited by humorgram on 11-20-2008 11:22 AM
Message Edited by humorgram on 11-20-2008 11:25 AM
Download All
0 Kudos
Message 1 of 7
(3,477 Views)
bump
0 Kudos
Message 2 of 7
(3,459 Views)
I am pretty sure your third data point should be [0.5 ; 0.99875] and not  [0.5 ; 99875] . It is off by a factor of 100000!
0 Kudos
Message 3 of 7
(3,455 Views)

To fit a function to a model you should use the "nonlinear curve fit" tools. It seems weird to calcuate the sum of squares inside the fit function and then use optimization.

 

Here's a simple rewrite, see if it makes sense.

 

(of course with periodic funtions you need to be very careful that you don't fit to an alias frequency).

0 Kudos
Message 4 of 7
(3,451 Views)

altenbach,

 

Good catch on the missing decimal for the data point in the cosine function. Before attaching the VIs I hastily entered default values and must have typed one. I'm aware of the problems fitting periodic functions. Thankfully, my particular function is not periodic. I was finally able to fit my parameters to my function using Unconstrained Nonlinear Optimization with the Downhill Simplex implementation, Quasi-Newton and Conjugate Gradient will not converge. Can the "nonlinear curve fit" tool be used for functions with two independent variables?

 

-Frank

0 Kudos
Message 5 of 7
(3,441 Views)

humorgram wrote:
Can the "nonlinear curve fit" tool be used for functions with two independent variables?

Yes, of course! 🙂

0 Kudos
Message 6 of 7
(3,431 Views)

Hi Altenback,

So what is the difference between using the L-M curve fit subVI and the optimization subVI?

I am also working on this and have used L-M curve fitting subVI but I have been told this is not a good approach due to the non-uniqueness problem.

0 Kudos
Message 7 of 7
(3,028 Views)