Hi
I have found matlab to behave unexpectedly when using the symmatrix. I dont understand it, maybe i misunderstood the way operators work, or maybe its a bug?
Any help would be greatly appreciated! Thank you!
I declare some symbolic objects using symmatrix
lambda = symmatrix('lambda', [n,1]);
g = symmatrix('g', [n,1]);
phi = symmatrix('phi', [n,1]);
l = symmatrix('l', [n,1]);
item = symmatrix('l', [n,1]);
I declare 2 almost identical equations
arga = (l.'*(((lambda).*(A * g) + (phi.'*lambda) * (A * g))));
argb = (l.'*(((lambda).*(item) + (phi.'*lambda) * (A * g))));
arga and argb should be the interchangable, as both item and A*g are 2x1 parameter vectors.
I differenciate wrt lambda:
sola = diff(arga, lambda)
solb = diff(argb, lambda)
I get
l.'*(symmatrix(eye(2)) .* A*g + kron(phi.', A*g))
l.'*(kron(phi.', A*g) + symmatrix(eye(2)) .* l)
ProbIem 1: I cannot evaluate the sum in the parenthesis of sola due to dimensionality issues. the probelm doesnt appear for solb.
Problem 2: Running the numerical example below, sola and solb give two results different whereas this should not be the case
l.'*((eye(2)) .* A*g + kron(phi.', A*g))
l.'*(kron(phi.', A*g) + (eye(2)) .* l)
I get