- 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
조회 수: 16 (최근 30일)
이전 댓글 표시
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
답변 (1개)
the cyclist
2011년 12월 9일
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)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!