I'm getting a very confusing logic error in a MATLAB code.
two matrices K and D' are equal (isequal(K,D') gives 1)
while B*D' and B*K are not.
I know if I remove the permute and reshaping, then the problem is solved but this code here is a part of a larger project and it's not possible to do so.
The minimal code to reproduce the error is
GT = rand(7,48,48);
GT_perm = permute(GT,[2 3 1]);
t_GT = rand(122,3);
B = rand(122,7);
param = [t_GT(:)',GT_perm(:)'];
K = reshape(GT,7,);
D = reshape(param(3*122+1:end),48^2,size(B,2));
ex_DB = B*D';
Image = B*K;