Non linear multiple curve fitting

16 Ansichten (letzte 30 Tage)
Alessio Pricci
Alessio Pricci am 14 Mär. 2022
Bearbeitet: Torsten am 15 Mär. 2022
Dear all,
I'm trying to do the multiple nonlinear regression of some rheology curves (rheology.png). In particular, viscisty (visc.txt) changes with both temperature (T.txt) and shear rate (shear_rate.txt).
I would find a nonlinear regression of the form given in the attached 'regression_model.txt', where eta is the viscosity, T the temperature and gamma the shear rate.
but I'm having problems... I tried with nonlinfit, but this worked on only if a fix a given value of temperature (so, for a single variable the regression was ok).
How can I perform this regression in a simple way?
I would thanks in advance anyone who will contribute to help me
Best regards,
AP

Akzeptierte Antwort

Torsten
Torsten am 14 Mär. 2022
Bearbeitet: Torsten am 14 Mär. 2022
Form a big matrix A:
First column: a vector of 1's
Second column: log(gamma) or log10(gamma) (depending on what "lg" means)
Third column: (log(gamma)).^2 or (log10(gamma)).^2 (depending on what "lg" means)
Fourth column: T*log(gamma) or T*log10(gamma) (depending on what "lg" means)
Fifth column: T
Sixth column: T.^2
and a big vector b, consisting of one column with the corresponding values for log(eta) or log10(eta) ( (depending on what lg means)
Then you can solve for the vector v =[ A0; A1; A11; A12; A2; A22] of constants in your model by typing
v = A\b.
  5 Kommentare
Torsten
Torsten am 14 Mär. 2022
Bearbeitet: Torsten am 15 Mär. 2022
D1 = 7.40688e+12;
D2 = 373.15;
A1 = 30.62;
A2 = 51.6;
n = 0.2411;
tau = 72297.9;
T1 = 210+273.15;
T2 = 245+273.15;
T3 = 280+273.15;
shear_rate=(linspace(1e-1,1e4,1e5)).';
V = @(T) D1*exp(-(A1*(T-373.15))./(A2+(T-373.15)))./((1+((D1*exp(-(A1*(T-373.15))./(A2+(T-373.15)))).*shear_rate./tau)).^(1-n));
T = T1;
v1 = V(T1);
T = T2;
v2 = V(T2);
T = T3;
v3 = V(T3);
A = [ones(3*numel(shear_rate),1),...
[log10(shear_rate);log10(shear_rate);log10(shear_rate)],...
[(log10(shear_rate)).^2;(log10(shear_rate)).^2;(log10(shear_rate)).^2],...
[T1*log10(shear_rate);T2*log10(shear_rate);T3*log10(shear_rate)],...
[T1*ones(numel(shear_rate),1);T2*ones(numel(shear_rate),1);T3*ones(numel(shear_rate),1)],...
[T1^2*ones(numel(shear_rate),1);T2^2*ones(numel(shear_rate),1);T3^2*ones(numel(shear_rate),1)]];
b = [log10(v1);log10(v2);log10(v3)];
v0 = A\b
v = lsqnonlin(@(x)fun(x,A,b),v0)
T = T3;
aaaa = v(1) + v(2)*log10(shear_rate) + v(3)*(log10(shear_rate)).^2 + v(4)*T.*log10(shear_rate) + v(5)*T + v(6)*T^2;
aaaa = 10.^(aaaa);
%% Graphical representation
loglog(shear_rate,aaaa,'b-',shear_rate,v3,'r-');
function res = fun(x,A,b)
res = 10.^(A*x) - 10.^b;
end
Torsten
Torsten am 14 Mär. 2022
Be careful with the log-expressions:

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by