Fitting sum of exponential function with experiment data

17 views (last 30 days)
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.

Answers (2)

Sayyed Ahmad
Sayyed Ahmad on 4 Jun 2019
you have to simplified your model to
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:
y=1-exp(-0.1*x); % 0.1 in your case would be is c2*De;
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

Arturo Gonzalez
Arturo Gonzalez on 8 Sep 2020
Per this answer, you can do it with the following matlab code
clear all;
% 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;
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);
% get exponentials multipliers
X = [ones(size(x)), exp(lambdas'.*x)];
P = pinv(X)*y;
% show estimate
y_est = X*P;
plot(x, y); hold on;
plot(x, y_est, 'r--');

Community Treasure Hunt

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

Start Hunting!

Translated by