- I put in some random exponential data
- I reordered your a and b variables as input, because I think you had them switched
- I put the fitting parameters into one vector
Nlinfit
13 views (last 30 days)
Show older comments
Im trying to fit a non linear curve as below;
x=areas40{1}(3,:); >> [a,b]=hist(x,30); >> mdl=@(a,b,x)(-a*exp.^-b); >> mdl=@(c,d,x)(-c*exp.^-d); >> b0=1; >> nlintool(a,b,mdl,b0); ??? Error using ==> nlinfit at 120 Error evaluating model function '@(c,d,x)(-c*exp.^-d)'.
Error in ==> nlintool at 193 [ud.beta, residuals, J] = nlinfit(x,y,model,beta0);
Caused by: Error using ==> exp Not enough input arguments.
and im struggling to understand why an help would be appreciated
thanks
0 Comments
Answers (1)
the cyclist
on 9 Dec 2011
Since I don't know what "areas" is, it is not possible for me to try to run your code.
However, I notice that you wrote, for example,
>> exp.^-b
That is not correct MATLAB syntax. exp() is a function that requires an argument; it is not the value "e". So, I am guessing you meant maybe
>> exp(-b*x)
but I am not quite sure.
ADDED LATER:
Here is a snippet of code in which I took your attempt, and changed several things to make it function.
So, this works, but you definitely need to see if it is close to what you want to do.
x = exprnd(1,[100000 1]);
[a,b]=hist(x,30);
mdl=@(ab,x)(ab(1)*exp(-x*ab(2)));
ab0=[1;0];
nlintool(b,a,mdl,ab0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!