solving a matrix exponential equation

9 views (last 30 days)
I know this is perhaps a "methods" question rather than a purely "Matlab" question, but does anybody know or could point me towards a way to estimate/fit the parameters of a matrix exponential equation?
In particular, if x is a NxM matrix representing a vector timeseries (each column x(:,n) is an observed N-dimensional vector) I would like to fit this data to a model of the form:
x(:,n) = expm(A*n)*b;
(note that this is matrix exponentiation, not element-wise exponentiation) where the matrix A (NxN matrix) and the vector b (Nx1 vector) are parameters to be estimated from the data in a way that minimizes the mse of the fit:
x_fit = cell2mat(arrayfun(@(n)expm(A*n)*b, 1:size(x,2),'uni',0));
err = mean(sum(abs(x_fit-x).^2,1),2);
Thank you for any pointers/thoughts/comments!

Accepted Answer

Star Strider
Star Strider on 17 Jun 2015
Very interesting problem! The solution parallels the technique used to fit differential equations using curve fitting functions. It is necessary to use lsqcurvefit for your function, because it supports matrix dependent variables. The code is straightforward.
It runs, but you will have to experiment with it to get it to work with your parameter set and data:
function y = matexp(b,t)
f = @(b,t) expm([b(1) b(2); b(3) b(4)]*t)*[b(5); b(6)];
for k1 = 1:N
y(:,k1) = f(b, t(k1));
B0 = rand(6,1);
N = 20;
t = linspace(0, 2*pi, N);
x = [cos(t); sin(t)];
B = lsqcurvefit(@matexp, B0, t, x)
for k1 = 1:N
x2(:,k1) = f(B, t(k1));
plot(t, x)
hold on
plot(t, x2)
hold off
I ran these in a nested function file, but you will probably find it easier to save ‘matexp’ as a separate function file.

Sign in to comment.

More Answers (0)


Find more on Linear Algebra in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by