n=5;
A=rand(n,n,2,2);
utrue=rand(n,2);
f=tensorprod(A,utrue,[2 4],[1 2]);
A=permute(A,[1,3,2,4]);
A=reshape(A,2*n,2*n);
u=A\f(:); %solve
[u(:), utrue(:)]
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!