MPFIT/MPFIT2DFUN (Markwardt) [message #22929] |
Fri, 22 December 2000 13:24  |
endobeck
Messages: 1 Registered: December 2000
|
Junior Member |
|
|
I have one-dimensional x, y, and z arrays, with x & y being positions
(independent variables), and z being an array of dependent variable
values. All 3 arrays have the same number of elements.
I'd like to fit a function of two variables (a plane) to the
data, and I've been trying to use MPFIT2DFUN. It seems I have to make
the x & y arrays into 2-d arrays, but I am not clear as to why or how.
Can someone fill me in?
Cheers,
Eli
Sent via Deja.com
http://www.deja.com/
|
|
|
Re: MPFIT/MPFIT2DFUN (Markwardt) [message #23073 is a reply to message #22929] |
Sat, 23 December 2000 13:07  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Greetings!
The function MPFIT2DFUN is designed to fit gridded 2-dimensional data,
ie an image.
However, the task you are asking, a scalar function of two variables,
is not very hard to do with the standard MPFITFUN. I even cover it as
a frequently asked question on my web page (hint, hint...).
What you want to do is make a *single*, *two*-dimensional independent
variable consisting of both your X and Y data. MPFITFUN doesn't care
that your independent variable is of different dimension than the
dependent variable. Your new independent variable would be
constructed like this:
XY = [[X],[Y]]
You would call MPFITFUN with XY as your independent variable, and Z as
your dependent variable. You need to make sure that your user
function can split this independent data array apart:
function myfunc, xy, p
x = xy(*,0)
y = xy(*,1)
... continue with calculations ...
end
Good luck,
Craig
endobeck@my-deja.com writes:
> I have one-dimensional x, y, and z arrays, with x & y being positions
> (independent variables), and z being an array of dependent variable
> values. All 3 arrays have the same number of elements.
>
> I'd like to fit a function of two variables (a plane) to the
> data, and I've been trying to use MPFIT2DFUN. It seems I have to make
> the x & y arrays into 2-d arrays, but I am not clear as to why or how.
> Can someone fill me in?
>
> Cheers,
> Eli
>
>
> Sent via Deja.com
> http://www.deja.com/
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|