# nonlinear regression

조회 수: 1(최근 30일)
john birt 2011년 2월 20일
After spending five hours reading how to use matlab for nonlinear regression I am so confused. I'm sure there must be some simple way to use a Non linear regression.
I have a function
y = m*x+d*g+d*(g^(1/k)+b^2+(b-x)^2)^k
where Im trying to find parameters m,d,g,k,b with 0<k<1
I have (x,y) data such as
(0.01, 0.00000020369272)
(0.02, 0.00000040738543)
(0.03, 0.00000061107815)
etc...
Is there some simple way to use Matlab to find the parameters?

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

### 채택된 답변

Matt Tearle 2011년 2월 21일
If you have Statistics Toolbox, you can use nlinfit, although there's no guarantee that k will be in the interval (0,1). Make a function handle to your function:
f = @(c,x) c(1)*x+c(2)*c(3)+c(2)*(c(3)^(1/c(4))+c(5)^2+(c(5)-x).^2).^c(4);
f is a function of the parameters ( c ) and x. Make an initial guess of the parameters:
c = rand(5,1);
Then call nlinfit with the data you have:
cfit = nlinfit(xdata,ydata,f,c)
If you don't have Stats TB, you can brute-force it in MATLAB by making an error function to minimize. Define f as above. Then define
g = @(c) norm(f(c,xdata)-ydata);
Now use fminsearch to find the coefficients, starting with an initial guess (as before)
cfit = fminsearch(g,c)
If you have Optimization Toolbox, you can use fmincon to constrain k.
##### 댓글 수: 4표시숨기기 이전 댓글 수: 3
Can I ask how to initialize the parameters in a better way, so that it doesn't change with every run because random numbers don't really solve the problem?

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

### Community Treasure Hunt

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

Start Hunting!