Code:

clear all
%-----VARIABLE SET-UP--------------
A = [0 1 0; 0 0 5; 1 2 3];
Q = [1 0 0; 0 0.5 0; 0 0 0.9];
%-----TO RUN and PLOT ODE SOLUTION--------------
t01= 0;
tf1=30;
tspan1 = LINSPACE(t01, tf1);
X01=zeros(3);
[Time1,X1] = ode45(@(t,X) odefuncare(t,X,A,Q),tspan1,X01);
plot(Time1,X1)
%-------ODEFUNCTION------------------
function dxdt = odefuncare(t,X,A,Q)
X = reshape(X,3,3); %converting X from a column vector generated by ode45 into a 3 x 3Matrix
dxdt=A*x +x*A’ +Q
dxdt = dxdt(:); %converting dxdt into a column vector as expected by ode45