NonLinear Line Fitting - forced/constrained

Hi
I am really stuck on this. So I have two vectors
x=0:10; y=y+rand(1,11)*2;
Now I want to fit a variety of curves to this, specifically - linear,exponential,logarithmic,logistic and power.
My problem is what ever model i use I want to force the curve to go through {0,0} i.e constrain this point
I have been trying my hardest to figure out how to use fmincon but have had no luck. I have tried to use lsqlin (after linearising the models).
Can someone please give me a short example code using fmincon fitting a simple exponential model ae^{bx}? I think once I know how to fit one I can figure out all the rest :)
Thanks for any help
-----------------------------
I have figured out so far that to do this i need to use Aeq and beq. But I have been able to define a function in fmincon which can take two arguments
i.e
function f = myfun(p,x)
f = p(1).*exp(p(2).*x)
how do i pass my x vector into fmincon

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 9 日

0 投票

1 件のコメント

Sam
Sam 2011 年 8 月 9 日
thank you
For a simple linear regression i could just omit the intercept and thus force the line though zero. But if i want to implement a nonlinear model (one i can not linearise) then I need to use something more complex. From reading it seems that i should use fmincon

この質問は閉じられています。

タグ

質問済み:

Sam
2011 年 8 月 9 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by