solving a matrix exponential equation

조회 수: 10 (최근 30일)
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2015년 6월 17일
댓글: Star Strider 2015년 6월 17일
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!

채택된 답변

Star Strider
Star Strider 2015년 6월 17일
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
Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2015년 6월 17일
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 2015년 6월 17일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by