Non linear least squares regression
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
the cyclist
am 8 Dez. 2011
If you have the Statistics Toolbox, you should be able to do this with the nlinfit() function.
3 Kommentare
the cyclist
am 8 Dez. 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
Siehe auch
Kategorien
Mehr zu Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!