Why does kron(D,I), with D and I both sized (nxn), not create a matrix sized (n^2 x n^2)?
1 view (last 30 days)
I am trying to run a code that involves operating on the elements of a matrix made by a kronecker sum operation, but I meet a sub2ind error. I have found that the problem is that MATLAB doesn't generate the matrix size it is supposed to generate after one kind of kronecker product operation in particular:
x = sym('x', [1 15], 'real')
I = eye(5)
D = diag(-x(1) -x(2) -x(3) -x(4) -x(5))
Which causes an error in my code that involves the following:
DsumD = kron(D,I) + kron(I,D)
zeta = sym(zeros(1,25));
for i = 1:25
zeta(1,i) = -DsumD(i,i);
zetatopi = sym(zeros(1,25));
for j = 1:25
zetatopi(1,i) = log(1+zeta(1,i)*x(15))/x(15);
DsumDtopi = diag(-zetatopi)
Does anyone know how I can make MATLAB do the kronecker operations properly?