Fitting tool for experimental data

Good morning,

I have a number of experimental samples

X= [x1, x2, …, xn]

Y = [y1, y2, …, yn]

and I would like to fit them with the following equation:

y = c1*x^c2 + c3

Could you suggest a tool to evaluate the coefficients c1, c2, c3?

Hello User1
This is a standard nonlinear regression problem, and some of them are difficult to solve.
Within Octave the tools provided are leasqr(), nonlin curvefit(), and fsolve(). They are in the Optimization toolbox.
I wrote a simple GUI, find it at Octave Information
or the linear GUI at
the nonlinear GUI at
and the (essential) documentaion at

In my very recent book (flagrant add, sorry) “Octave and MATLAB for Engineering Applications” by Springer in section 3.2 (starting on page 219) find extensive documentaion about linear and nonlinear regression

I hope this helps
Andreas Stahel

P.S. If you send me your data I give it a try.

Dear Dr Stahel,

Thank you for your reply.

I would appreciate it if you could have a look at my data.


samples.m (910 Bytes)

Sometimes fminsearch in core can also be useful.

Enclosed my solution, using your data.
The comments in the code describe the path to the solution.
I use a local version of leasqr.m, since the one in the package optim
has a problem.

I hope it helps


dfdp.m (2.6 KB)
leasqr.m (11.5 KB)
samples.m (1.6 KB)

Hello again

Ooops, the version in the optim package works, it is just using function handles.
Enclosed a version to use either leasqr() or nonlin_curvefit(), both from the optim package.

samples.m (2.1 KB)


Dear Dr Stahel,

The file samples.m works perfectly.

Thank you for having suggested a new equation to fit the data.


Thank mmuetzel for your advice

@AndreasStahel: Thank you for your expertise and willingness to help @User1.

I see in your page Octave Information that you’re linking to the Octave Forge package collection at SourceForge. You may be aware that it has now been superseded by the much larger Octave package collection on Github itself. Could you add a link to that pls? GNU Octave - Packages

Background: Welcome Octave Packages!

1 Like

Hello Arun

Thank you for the constructive hint.
I will add a link to the github package collection.


1 Like

I also tried fitting your data to 2 exponential equations.
samples3.m (1.4 KB)

It did not do a very good fit but you might like it anyway.

Thanks Dastew.