Nlinfit

조회 수: 16 (최근 30일)
Matt
Matt 2011년 12월 9일
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

답변 (1개)

the cyclist
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.
  • 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
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)
  댓글 수: 1
Matt
Matt 2011년 12월 9일
Basically I am looking at the distribution of Facet areas over a crumpled piece of paper and i get an almost exponential distribution it might be a stretched exponential as above or something similar but basically im struggling to plot a non linear curve to it :/

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by