Hi! I am trying to write in a more efficient way the following code, possibly without the for cycles.
Thank you in advance. var1, var2 are N x N x N arrays. var3 is a N X N array.
function sum = kronecker_sum(var1,var2,var3)N = size(var1,1);sum = zeros(N^2,N^2);for i = 1:N for j = 1:N sum = sum + kron(var1(:,:,i),var2(:,:,j))*var3(i,j); endendend
Best Answer