Nonlinear least square regression

Hi all i have 17 observation (x and y) the relation between them as follows
y = 0.392 * (1 - (x / J)) ^ i
i want to use nonlinear least square regression to know J and i
Thanks in advance

 채택된 답변

Eli Duenisch
Eli Duenisch 2013년 5월 23일
편집: Eli Duenisch 2013년 5월 23일

0 개 추천

Do you have the statistics toolbox installed? It supports nonlinear regression - look for NonLinearModel.fit() in the docs.

댓글 수: 5

ameen
ameen 2013년 5월 23일
i have it installed
ameen
ameen 2013년 5월 23일
mdl = NonLinearModel.fit(X,y,modelfun,beta0)
i think i can use this one so i have 17 x and 17 y
how can i put my modelfun and beta0 ??
Tom Lane
Tom Lane 2013년 5월 24일
For modelfun: either write a function or use 'y ~ .392*(1-x/b1)^b2'. The function will be happier if you use names b1/b2 in place of J/I.
For beta0: give a two-element vector with your best guess at b1 and b2. This depends on your data. A good guess gives the function a better shot at solving the problem. If you have real data, you might consider something like b1=2*max(x) to avoid problems with complex numbers.
ameen
ameen 2013년 5월 24일
thank you for your kind reply but i put my x values, then my y values, and put beta0=[0.65,1.1] then i write
mdl=nonlinearmodel.fit(x ,y ,'y=0.392*(1-x/b1)^b2',beta0)
and i received error message ' Undefined variable "nonlinearmodel" or class "nonlinearmodel.fit".'
Tom Lane
Tom Lane 2013년 5월 24일
Try NonLinearModel.fit capitalized just that way. This should work in the most recent releases of MATLAB. Otherwise try nlinfit.

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

추가 답변 (0개)

카테고리

태그

질문:

2013년 5월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by