![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552447/image.jpeg)
Fitting a sum of exponentials to data (Least squares)
16 ビュー (過去 30 日間)
古いコメントを表示
How do I find
and
given
and
in the model
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552307/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552312/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552317/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552322/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552327/image.png)
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552332/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552337/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552342/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552347/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552352/image.png)
Answer in the exercise sheet:
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552357/image.png)
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;
0 件のコメント
回答 (1 件)
Alan Stevens
2021 年 3 月 16 日
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/552447/image.jpeg)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!