Asked by aditi
on 22 Jan 2014

I have x and y coordinates and I want to fit an equation:

y=a*exp(x^b - 2^b)

to the data set and thus finding parameters a and b. Please help me through it.

*No products are associated with this question.*

Answer by Amit
on 22 Jan 2014

Accepted answer

First make a function that you'll use to fit like this:

function val = myfunc(par_fit,x,y) % par_fit = [a b]

val = norm(y - par_fit(1)*exp(x.^2-2^par_fit(2)));

Now, find the parameters like:

my_par = fminsearch(@(par_fit) myfunc(par_fit,x,y),rand(1,2));

Show 32 older comments

Amit
on 23 Jan 2014

I did exactly what I told you earlier, just changed it to the new equation you mentioned.

I get values for a and b as, 5.55e7 and 7.12e7. Very Very high from what you said!!

I posted that plot because I wanted to show you that with limited number of data, you cannot estimate parameters for a very nonlinear function. You have to be very careful, especially in research, on how to determine parameters and then trust it.

aditi
on 23 Jan 2014

one more thing...what i found after googling is that in such cases u have to give a specific range for 1 of the parameter... so any idea about that..??

like in above equation if i deliberately want that the b value should lie betweem 0.2 and 2 and then find a and b...how can i do that???

Answer by Matt J
on 22 Jan 2014

You might also try FMINSPLEAS. It can take advantage of the fact that y has a linear dependence on one of the parameters 'a'.

Show 3 older comments

Matt J
on 22 Jan 2014

norm(y - par_fit(1)*exp(x.^2-2^par_fit(2)))

measures the distance between the vector y of given curve samples and the vector

par_fit(1)*exp(x.^2-2^par_fit(2))

of fitted curve samples.

fminsearch tries to find the par_fit(1) and par_fit(2) that minimizes this distance, giving best agreement between y and your parametric curve model.

Opportunities for recent engineering grads.

## 0 Comments