Effacer les filtres
Effacer les filtres

Fitting a sum of exponentials to data (Least squares)

16 vues (au cours des 30 derniers jours)
Nour Butrus
Nour Butrus le 16 Mar 2021
How do I find and given and in the model
which describes the decay of two materials. Nis the total amount of material remaining after t hours, and and is the amount of material at (B is just a background constant).
I have solved it according to this paper, however my answer is not optimal compared to what the answer is supposed to be (according to an exercise sheet).
Below is what I did, note that and and the matrix a contains the parameters wanted.
Answer in the exercise sheet: .
x=[0.5 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0];
y=[5995 4930 3485 2550 1910 1500 1085 935 830 655 585];
p=-0.5;
q=-0.2;
G=[length(x), sum(exp(p.*x)), sum(exp(q.*x));
sum(exp(p.*x)), sum(exp((2*p).*x)), sum(exp((p+q).*x));
sum(exp(q.*x)), sum(exp((p+q).*x)), sum(exp((2*p).*x))];
h=[sum(y);sum(y.*exp(p.*x));sum(y.*exp(q.*x))];
a=(G)\h;

Réponses (1)

Alan Stevens
Alan Stevens le 16 Mar 2021
Use Matlab's best-fit matrix approach as follows:
t=[0.5 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0];
N=[5995 4930 3485 2550 1910 1500 1085 935 830 655 585];
p=-0.5;
q=-0.2;
E1 = exp(p*t);
E2 = exp(q*t);
% [E1 E1 1]*[N1; N2; B] = N
M = [E1' E2' ones(numel(t),1)];
% Least squares best-fit
NB = M\N';
N1 = NB(1);
N2 = NB(2);
B = NB(3);
tt = 0.5:0.1:10;
NN = N1*exp(p*tt) + N2*exp(q*tt) + B;
plot(t,N,'o',tt,NN), grid
xlabel('t'), ylabel('N')
legend('data','fit')
This results in

Catégories

En savoir plus sur Least Squares dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by