# ndsolve interpolatingfunctions not shown/evaluated

Using this technique from Simon, I want to solve a matrix differential equation with a matrix that contains an explicit time-dependence(our variable), but I want to be able to solve this problem for a generic number of functions K+1 thus auto-indexing them. My code, stripped of a few things which don't seem to be the problem, (with I= imaginary unit):

K=2;

dl = ConstantArray[ 1/2 Exp[-I t], K];       %defining M
dm = Array[(# - 1)^2 &, K + 1];
dr = ConstantArray[1/2 Exp[I t], K];
M = SparseArray[{Band[{1, 2}] -> dr, Band[{1, 1}] -> dm,
Band[{2, 1}] -> dl}] // Normal

a[t_] := Table[g[k][t], {k, 0, K}]          %defining a as a list of functions g

NDSolve[{a'[t] == I *M.a[t], g == 0, g == 1, g == 0}, {g, g, g}, {t, 0, 10}][[1, All, 2]] //Abs
%solving the diff. eq.


Which returns a list of three InterpolatingFunctions with output scalar as I would expect. However,

Plot[%,{t,0,10}]


Only draws axes without any graphs. But I solved these equations for K=2 beforehands in another way(but still with DSolve) and saw some results which should also be shown the domain of this graph, but are missing. Similarly, function evaluation for a random value of t

%%


Doesn't give a number either.

My intention when this works for a generic K is add a manipulate to change some parameters I put equal to one now and make the whole thing a function of K.

• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Oct 22 '15 at 13:32
• Just a reminder: (*comments look like this in Mathematica*), single line comments aren't really used. The answer here provides some discussion on the topic. Oct 22 '15 at 13:40

sol = NDSolveValue[{a'[t] == I*M.a[t], g == 0, g == 1, 