Nlinfit

2 ビュー (過去 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 Center および File ExchangeExploration and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by