Non linear least squares regression
Afficher commentaires plus anciens
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
Réponses (1)
the cyclist
le 8 Déc 2011
0 votes
If you have the Statistics Toolbox, you should be able to do this with the nlinfit() function.
3 commentaires
David
le 8 Déc 2011
David
le 8 Déc 2011
the cyclist
le 8 Déc 2011
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
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!