I want to solve a linear system in MatLab (corresponding to the PDE system of two equations written in a difference scheme). The action of the system matrix (corresponding to one of the diffusion terms of the PDE system) is read symbolically ( uis one of the unknown fields, nis a time step, jis a grid point):


and completely:

The above matrix should be denoted as A, where A * U ^ n + 1 = B is a system. ucontains 'u' and 'v' (second unknown field of the PDE system): U = [u_1, v_1, u_2, v_2, ..., u_J, v_J]. Until now, I filled this matrix, using spdiagsand diagfollowing expensive way:
E=zeros(2*J,1);
E(1:2:2*J) = 1;
E(2:2:2*J) = 0;
Dvec=zeros(2*J,1);
for i=3:2:2*J-3
Dvec(i)=D_11((i+1)/2);
end
for i=4:2:2*J-2
Dvec(i)=D_21(i/2);
end
A = diag(Dvec)*spdiags([-E,-E,2*E,2*E,-E,-E],[-3,-2,-1,0,1,2],2*J,2*J)/(dx^2);`
and to solve
[L,U]=lu(A);
y = L\B;
U(:) =U\y;
where Bis the vector of the right side.
, JxJ, JxJ ..
: , MatLab , , Dvec , , D_11 D_22?
!