news:jhdt6h$b5s$1...@newscl01ah.mathworks.com...
Don't "poof" variables into your workspace like that. Call LOAD with an
output argument and refer to the fields of those struct arrays instead.
> x=time;
> y=counts;
>
> q;
>
> p=[a,b,c];
> p0=[320,0.55,2];
>
> [ahat,r,J,cov,mse]=nlinfit(y,x,p,q);
This won't work for two reasons. First, this attempts to call q with zero
input arguments and pass the output of that call into NLINFIT as the fourth
input. Even if you replaced that with @q it still wouldn't work.
You will need to specify the fun input argument using an anonymous function
adapter, since NLINFIT requires the function that you pass to it be a:
http://www.mathworks.com/help/toolbox/stats/nlinfit.html
"Function specified using @ that accepts two arguments:
A coefficient vector, say b
The array X"
So instead of trying to pass in q or @q, do this:
myfun = @(b, x) q(b(1), b(2), b(3), x);
[ahat, r, l, cov, mse] = nlinfit(y, x, p, myfun);
Now myfun presents to NLINFIT the interface it expects (a two-input
interface) and calls q using the interface it expects (a four-input
interface.)