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