help with nonlinear regression

Hi, I'm trying to perform a non-linear regression analysis on my data because linear regression is not fitting the data (as you can see on the figure bellow)
It seems (for me) that the data will fit a 1/x-ish function but I don't know how to program it with the matlab function: nlinfit(X,Y,modelfun,beta0)
Can someone help me to perform the non linear regression and plot the resulting function? Thanks

 採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 3 月 1 日

0 投票

Your data does not represent a function at all (there are multiple values of y for an x)
Are you interested in distribution fitting instead?
If you have the statistics toolbox, you can do nonlinear regression using NLINFIT or NonLinearModel.fit if you have a recent release of MATLAB.
Scroll down on the page to see examples, on how to use model fun. For 1/x will be @(x)1/x
Distribution fitting:

その他の回答 (1 件)

Pierre
Pierre 2013 年 3 月 1 日

0 投票

thanks Shashank I've tryed to use the nlinfit function. Here is a little exemple I've tried:
x=1:20
B=3*x.^-1
A=[B(1) B(4) B(5) B(9) B(10) B(18)]
x2=[1 4 5 9 10 18]
modelfun=@(a,x) a(1)./x
beta = nlinfit(x2,A,modelfun,0)
answer is beta = 3 so it worked. But your right my data does not represent any function :-(

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by