# Retrieving only first function in matrix ODE using NDSolve

I have a very stupid question, but I don't use Mathematica very often, so here it goes:

I'm trying to solve some "matrix" ODE using NDSolve. The matrix in question is 2x2, with each element being a function of time. After using NDSolve, I obtain four interpolating functions corresponding to the four elements of the matrix. However, I'm having trouble figuring out how to extract and plot only one specific element of the matrix.

For instance, in the code snippet below, I'm getting the correct solution, but it plots the entire first row of the matrix instead of just the element at position (1,1):

ClearAll["Global*"]
Clear[ρ, ρee, ρeg, ρge, ρgg, α, Γc, Γ0, σplus, σminus];

ρ[t_] = {{ρee[t], ρeg[t]}, {ρge[t], ρgg[t]}};
σplus = {{0, 1}, {0, 0}};
σminus = ConjugateTranspose[σplus];
α = 5;
Γ0 = 1;
Γc := α*Γ0;
ρ0 = {{1, 0}, {0, 0}};
sol = NDSolve[{ρ'[t] == ((Γc + Γ0)/2) (2*σminus.ρ[t].σplus -
σplus.σminus.ρ[t] - ρ[t].σplus.σminus), ρ[0] == ρ0}, ρ[t], {t, 0, 1}];

Plot[Evaluate[{ρee[t], ρeg[t]}/.sol] ,{t,0,0.5}]


I've tried using the Part function and referencing only ρee[t] but without success. Any assistance would be greatly appreciated.

• Maybe use Part outside Evaluate like this: Evaluate[{\[Rho]ee[t], \[Rho]eg[t]}/.sol][[1,1]]? Commented Apr 29 at 7:28

try this. Use

Flatten[ρ[t]]


ρ[t]

Plot[Evaluate[ρee[t] /. sol], {t, 0, 0.5}]
`