how do you create a model for a sum of exponentials?
22 ビュー (過去 30 日間)
古いコメントを表示
I am attempting to write a code with my input data and model it as a sum of exponentials. Depending on the curve, the algorithm needs to determine if the fit is robust enough (probably compare an error value) or if it is not to add another exponential term(ie a*exp(b*t)). Thus creating an equation of exponentials to properly fit the data the best it can. I have a formula to calculate the sum of squares error. I was going to use that value to determine if another term should be added.
Anyone know some sources that may be of use to help create the algorithm?
Thanks!
0 件のコメント
採用された回答
the cyclist
2015 年 7 月 2 日
If you have the Statistics and Machine Learning Toolbox, you can fit this type of model straightforwardly using the nlinfit function.
0 件のコメント
その他の回答 (2 件)
Arturo Gonzalez
2020 年 9 月 8 日
Per this answer, you can do it with the following matlab code
clear all;
clc;
% get data
dx = 0.001;
x = (dx:dx:1.5)';
y = -1 + 5*exp(0.5*x) + 4*exp(-3*x) + 2*exp(-2*x);
% calculate n integrals of y and n-1 powers of x
n = 3;
iy = zeros(length(x), n);
xp = zeros(length(x), n+1);
iy(:,1) = cumtrapz(x, y);
xp(:,1) = x;
for ii=2:1:n
iy(:, ii) = cumtrapz(x, iy(:, ii-1));
xp(:, ii) = xp(:, ii-1) .* x;
end
xp(:, n+1) = ones(size(x));
% get exponentials lambdas
Y = [iy, xp];
A = pinv(Y)*y;
Ahat = [A(1:n)'; [eye(n-1), zeros(n-1, 1)]];
lambdas = eig(Ahat);
lambdas
% get exponentials multipliers
X = [ones(size(x)), exp(lambdas'.*x)];
P = pinv(X)*y;
P
% show estimate
y_est = X*P;
figure();
plot(x, y); hold on;
plot(x, y_est, 'r--');
0 件のコメント
Image Analyst
2020 年 9 月 8 日
The attached demo fits any number of Gaussians to a signal. The demo uses 6 as an example, but you can change it to however many Gaussians you want.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!