Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Marc
Posts:
81
Registered:
7/2/10
|
|
Re: nlinfit
Posted:
Mar 10, 2013 3:42 AM
|
|
"Samantha" wrote in message <khg172$cdl$1@newscl01ah.mathworks.com>... > I am trying to nonlinear fit this equation: > > r=k'Ca + ((k Ka Ca)/(1+Ka Ca + Kw Cw)) > > I have values for r, Ca, and Cw. I need to get k', k, Ka, and Kw. In Matlab I did this: > > I created an M file > > function f=order1(a,x1,x2) > f=(a(1)*x1)+((a(2)*a(3)*x1)/(1+a(3)*x1+a(4)*x2)); > > then in the workspace I defined > f=[0; .0003; .0007; .0017; .0015; .0024; .002; .0025; .0031; .0073; .007] > x1=[0; 2; 5; 8; 8.5; 8.75; 9; 9.25; 9.5; 9.75; 10] > x2=[55.49; 44.88; 28.96; 13.03; 10.38; 9.05; 7.73; 6.40; 5.07; 3.75; 2.42] > > and my initial guesses > a=[.0001 .025 .14 1.25] > > then a=nlinfit(x1,y,'order1',a) > > and I keep getting this error > ??? Error using ==> nlinfit at 120 > Error evaluating model function 'order1'. > > Caused by: > Input argument "x2" is undefined. > > I'm not really sure how to fix this, I though I defined x2. Any help on this would be greatly appreciated. > > Thank, Sam
I will have double check but I believe you need to set up x1 and x2 as a single variable, x = [x1 x2]... Thus needing to change your function to x(1) and x(2).
|
|
|
|