I am working on a problem where I need to solve the master equation for a system and I need to find the correlation function of the form $\langle x(0)x(t)\rangle$ for any quantity (e.g. position etc.) $x$ that takes on discrete values $x = x_1, x_2,\cdots, x_N$ when the system is, respectively, in states $i = 1, 2, \cdots, N$. A detailed explanation and notation can be found in this pdf -http://makarov.cm.utexas.edu/resources/Lecture-notes,-tutorials-etc./master_equations.pdf
They derive the correlator function to be $x^Te^{-Kt}\bar{x}$ where K is the probability transition (master) matrix.How can I solve this numerically? Can anyone provide me with a matlab code for the same?
Edit1-From a source I got a matlab code for a system which does the same. Assume Wmat is the master equation matrix.
sizeWmat=size(Wmat,1);
[Umat,Dmat]=eig(Wmat,'nobalance');
for m=1:sizeWmat
currLambda=Dmat(m,m);
if abs(currLambda)>1e-9;
Dmat(m,m)=1/(currLambda*GammaTot);
else
Dmat(m,m)=0;
end
end
invUmat=inv(Umat);
And then they used Umat*Dmat*invUmat
in place of $exp(Wmat*t)$
Can somebody explain this?