There are many problems with your code.
There is a lowercase which
. Anyway, you should use Piecewise
, and not Which
, for symbolic math.
The equation
v[k]'[t] == (i[k][t] - i[k + 1][t])/Cv[k][t]
involves i[k+1]
. When k
ranges from 1
to NN
the last equation involves i[NN+1]
.
Qs[0][t]
is not defined, but is needed for Qs[1][t]
The definition
Ip[k_][t] :=
Ip[k - 1][t] + Multi[[k]]*Sum[i[j][t], {j, k, NN}, {t, 0., tmax}]
uses t
as both independent variable and iterator. What does it mean?