Non linear least squares regression

조회 수: 2 (최근 30일)
David
David 2011년 12월 7일
Hi All,
I am pretty new to MATLAB and am trying to perform a non-linear least squares regression on a vector of residuals generated from the equation:
AT+(ST/(1+(Ks*Z)/(f*H'))+(FT/(1+Kf/(f*H'))+((mo+m)/mo)*(f*H'/Z)-(m/mo)*C=0
where AT, ST, Ks, Kf, Z, FT, mo, & C are all values and f, H', & m are all vectors
I need to perform the regression by adjusting AT (a value) and f (a vector). Then I need to output the adjusted values of AT & f.
I've looked around, but I can't figure out how to do it.
Any help would really be appreciated. Thanks.
David

답변 (1개)

the cyclist
the cyclist 2011년 12월 8일
If you have the Statistics Toolbox, you should be able to do this with the nlinfit() function.
  댓글 수: 3
David
David 2011년 12월 8일
more specifically, I don't understand the syntax for the nlinfit function. For my example, I can't figure out what X, Y, Modelfun, and beta should all be.
the cyclist
the cyclist 2011년 12월 8일
I can't code your function for you, but here is a simple example I made for myself some time ago, to test a very simple quadratic fitting. Maybe it will help you figure it out.
function [] = nlinfitExample()
% Define the data to be fit
x=(0:1:10)'; % Explanatory variable
y = 5 + 3*x + 7*x.^2; % Response variable (if response were perfect)
y = y + 2*randn((size(x)));% Add some noise to response variable
% Define function that will be used to fit data
% (F is a vector of fitting parameters)
f = @(F,x) F(1) + F(2).*x + F(3).*x.^2;
F_fitted = nlinfit(x,y,f,[1 1 1]);
% Display fitted coefficients
disp(['F = ',num2str(F_fitted)])
% Plot the data and fit
figure(1)
plot(x,y,'*',x,f(F_fitted,x),'g');
legend('data','nonlinear fit')
end

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

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by