Hi Adham,
Just to be clear, it's an ordinary differential equation,
is
/
? If so, and each matrix term is separable, then you can just reorder them into a vector for the integration. So if the below is an accurate representation of your problem:
phi = [x1, x2;
x3, x4]
phi_prime = [dx1/dt, dx2/dt
dx3/dt, dx4/dt]
Then
function dx = myDeriv(t,x)
actual_x = x(1);
actual_x_prime = f(actual_x, t);
phi_vector = x(2:end);
phi_matrix = reshape(phi_vector,6,7)
A = getA(t);
dphidt_matrix = A*phi_matrix;
dphidt_vector = dphidt_matrix(:);
dx = [actual_x_prime;
dphidt_vector];
end
function A = getA(t)
end
And calling it:
phi0 = eye(6);
x0 = [actual_x0; phi0(:)];
tspan = [0 10];
[t,x] = ode45(@myDeriv,tspan, x0)
Finally reshape out your variables for each time point, because x will by n_t by 43 instead of the scalar vs time and matrix vs time variables you want:
actual_x_integrated = x(:,1);
phi_integrated = nan(6,7,length(t));
for ix =1:length(t)
phi_integrated(:,:,ix) = reshape(x(ix,2:end),6,7);
end
I believe that should do what you're after.