solving a matrix exponential equation

3 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));
end
end
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));
end
figure(1)
plot(t, x)
hold on
plot(t, x2)
hold off
grid
I ran these in a nested function file, but you will probably find it easier to save ‘matexp’ as a separate function file.
  2 Comments
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon on 17 Jun 2015
Thanks, this was exactly what I was looking for. And yes, not surprisingly this problems arises from a differential equation model of the timeseries of the form:
d/dt x(:,t) = A*x(:,t);
but I was finding that fitting the differential equation parameters on the data was resulting in relatively poor fits when integrating those equations to extrapolate beyond very short time spans, so I was hoping to fit the integral forms directly (and your answer lets me do exactly that). Thanks again!

Sign in to comment.

More Answers (0)

Categories

Find more on Linear and Nonlinear Regression 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!