[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Surface fitting

From: Markus Appel
Subject: Re: Surface fitting
Date: Mon, 23 Feb 2015 09:47:44 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/22/2015 09:14 PM, jlapin wrote:
> Hello Everyone
> I am currently working in a Pchem lab and am trying to model
> spectroscopy data. I have a 256 x 433 unit matrix of signal data.
> Each signal is a function of a wavelength value and a time value.
> So far I have used the functions "nonlin_curvefit" and "leasqr" to
> fit the data one row(or column) at a time. Now I would like to fit
> the entire surface to an equation that is a function of both time
> and wavelength.
> The inputs of the function leasqr are leasqr(*x,y,pin,f*). Y will
> be the 256x433 signal data, pin will be my initial parameter
> guesses and f will be my function handle. The problem I am having
> is the x vector(s) for independent values. This is a function of
> both the wavelength and time variables.
> What can I put in for the x argument so that the leasqr function
> fits the entire matrix?
> Thank you Joel
> -- View this message in context:
> Sent from the Octave - General mailing list archive at
> _______________________________________________ Help-octave mailing
> list address@hidden 

Hi Joel,

the 'x' vector is not actually used for fitting and just handed
through to your model function, so you are more or less free to put in
what you want. Especially leasqr might check that the dimensions are
equal to 'y' though, and complain if otherwise. nonlin_curvefit might
be more flexible, but I cannot try it out right now.

You can always wrap your model function before giving it to the
fitting routines to use multiple independent variables:
[...] = nonlin_curvefit( @(p,x) MyModel(p,lambda,t), pin, [], y);
(Not sure if empty vector for 'x' works. If not, give 'y' again as an
ugly trick ...)

The other and probably cleaner possibility is to use nonlin_residmin,
in that case you would need to calculate the residuals on your own:
[...] = nonlin_residmin( @(p) (MyModel(p,lambda,t) - y).^2 ./
errors.^2, pin);

Hope it helps,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]