Continue to Site

# Curve fitting in C for microcontroller

Status
Not open for further replies.

#### zereshki

##### Member level 1
Hello
I need to to make a curve fitting for measured data from A/D of micro in C. The function of curve is nonlinear and can not be lineared . so I need to use Levmar algorithm to find best fit. I test many source that have been written for pc and match them to micro but were not work and didn't find unknown parameters.
Is there somebody who implemented levmar curve fitting in micro controller work properly?

regards

What kind of function are you trying to fit to the measured data? Did you choose reasonable initial parameter values? Did you monitor the fitting progress?

What kind of function are you trying to fit to the measured data? Did you choose reasonable initial parameter values? Did you monitor the fitting progress?

data must be fitted to:

y = p[0] / x + p[1] tanh[ p[2] x ]

and find p[0] , p[1] , p[2]

results all p[] s are zero !

yes I choose initial parameters close to known values(in test program). of course in levmar algorithm even initial parameter be far from, the result are close to best fit.

If you start with non-zero initial parameters, the iterative process won't arrive at all zero in one step. By watching the parameters and error square sum, you get an idea what goes wrong.

To know reasonable parameters, you can perform the fit with a spread sheet calculator, e.g. the Excel solver.

If you start with non-zero initial parameters, the iterative process won't arrive at all zero in one step. By watching the parameters and error square sum, you get an idea what goes wrong.

To know reasonable parameters, you can perform the fit with a spread sheet calculator, e.g. the Excel solver.

yes you are right, I never initiate by zero one's. actually I make some numbers by the function plus some reasonable noise.

so I want any ready source that suited for micro without any unused function that have been writen for pc that make source huge code.

regards

Status
Not open for further replies.