# Creation of a matrix

I would like to write the matrix

v[s_,ss_,qi,qj] :=( {{a/(2 r) DiracDelta[s - ss], a/r(HeavisideTheta[(s - ss) + r] - HeavisideTheta[(s - ss) - r])}, {a/r(HeavisideTheta[(s - ss) + r] - HeavisideTheta[(s - ss) - r]), a/(2 r) DiracDelta[s - ss]}})

S[z_, i_, j_] := S[z, i, j] =Integrate[Sum[1/(M[[qi]]*M[[qj]])*u[s,i, qi]*v[s,ss, qi, qj]*udot[ss, qj, j], {qi, 2}, {qj, 2}], {ss, 0, z}], {s, 0, z}];

where

M[qi]={1,1,1,1} M[qj]={1,1,1,1}

• What is s, did you mean to index it as well? Did you mean KroneckerDelta instead of DiracDelta? – Roman Jul 27 '19 at 9:30
• I mean DiracDelta. – Dora Jul 27 '19 at 9:43
• But the right expansion of S is:S[z_, i_, j_] = NIntegrate[ NIntegrate[Sum[1/(M[[qi]]*M[[qj]])*u[s, i, qi]*vqiqj[s - ss]*udot[ss, qj, j], {qi, 2}, {qj, 2}], {ss, 0, z}],{s, , 0, z}] – Dora Jul 27 '19 at 9:53
• Please edit your question instead of giving info in the comments. – Roman Jul 27 '19 at 10:42
• Some hints: 1. You are using the variables qi and qj outside of the integrals in which they are defined. 2. qi and qj are real-valued integration variables but you are using them as integer-valued indices. 3. You have too many underscores in your definition of S, see this tutorial. 4. There's an extraneous comma in your summation over z. 5. Your definition of vqiqj should be in terms of a variable ds=s-ss, not in terms of s-ss. There's probably more. – Roman Jul 27 '19 at 11:24