k = 2;
F = inline("k*x^2", "x");
then,
F(2) = 8;
Now even if I change k after this, the function F will be unchanged.
Furthermore for leasqr, when you define F like this:
F = inline("Ao*exp(-D*x^2*k)","Ao","D","x")
You still have the problem that leasqr expects a function of the form:
f(x,p)
This implies two important things:
1) the function has exactly 2 input arguments
2) the x variable is the first argument.
This is the reason that I said to let p(1) be your Ao and p(2) be your D, so
that you can fit both the parameters that you want to optimize into one
input variable (namely p).
For leasqr your function (if it is inline) should always look like this:
F = inline("<some function with x and p>", "x", "p");
(Note: Notice this is not the same as writing F = inline("<some function>",
"p", "x"); The order you list the parameters after the function is the
order that octave will expect them when you call F, so "x" must be first for
leasqr)
This is also how you tell octave which variable is the independent one (it
is always the first argument of F) and the parameters to be optimized
(always the second argument of F).
So after you put it into this form and run leasqr, you can get the estimates
of Ao and D by doing:
estimateAo = p1(1);
estimateD = p1(2);