Fitting sum of exponential function with experiment data
조회 수: 13 (최근 30일)
이전 댓글 표시
I am trying to fit my experimental data with unipore diffusion model, which is a summation of exponential functions as given below.
t is the time, De is the diffusion coefficient that I need to find from the experimental data as a fitting parameter. Vt/V can be considered as y variable, which is directly measured from the experiment.
Could you help me to code this to obtain the De?
The experimental data sheet is attached.
Thank you.
댓글 수: 0
답변 (2개)
Sayyed Ahmad
2019년 6월 4일
you have to simplified your model to
y=1-c1exp(-c2*x*t)
y ist your Vt/V_inf
c1 represent all other parameter outside your exp() function
c2 represent all parameters inside exp funtion
t is the time
and x would be your De
now you can use the polyfit to find out your De value
for example:
x=1:10;
y=1-exp(-0.1*x); % 0.1 in your case would be is c2*De;
plot(x,y);
p=polyfit(x,-1*log(1-y),1); % p(1) would be c2*De and p(2) would be close to zero and you can ignore this
%De=p(1)/c2;
댓글 수: 0
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
참고 항목
카테고리
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!