solving a matrix exponential equation

3 visualizaciones (últimos 30 días)
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon el 17 de Jun. de 2015
Comentada: Star Strider el 17 de Jun. de 2015
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!

Respuesta aceptada

Star Strider
Star Strider el 17 de Jun. de 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 comentarios
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon el 17 de Jun. de 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!
Star Strider
Star Strider el 17 de Jun. de 2015
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by