1/x fit

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

1/x fit

Pierrick Hanlet
Hello all,
I'm using octave v4.0.3 on Fedora 25.

I have some data, call it xraw and yraw which follows a 1/x curve.
I'm attempting to minimize a function yraw-yfit, so as to get the
parameters 'p'.

function y=fitcal(p)
  global xraw yraw;
  yfit=p(1)+1.0./(p(2)*xraw);
  y = sqrt(sum((yraw-yfit).^2));
end

I'm attempting to use fminsearch, such that my call to the function is:

global xraw yraw;
...
sx=[100,0.00015];
xraw=TXI;
yraw=RXI;
[sx,fxval]=fminsearch(@(sx)fitcal(sx),sx);

Nothing that I try changes sx; i.e. the fitter always returns the initial
values
, so I'm assuming that my fit is failing.


I've successfully done something like this before with trig function.
So I'm wondering if my error is in the fact that I cannot set bounds
on p(2); namely p(2)!=0.0.

Is there something else that I'm missing?  Else, is there something
in Octave which mimicks Matlab fmincon?

Thank you,
Pierrick


--


-----------------------------------------
Join us March 12-15 at CERN near Geneva
Switzerland for OctConf 2018.  More info:
https://wiki.octave.org/OctConf_2018
-----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: 1/x fit

withaar
CONTENTS DELETED
The author has deleted this message.