MATLAB: What could be the cause of error “Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts”

errorMATLABnon-singleton

VEC1(:,:,z)=eVects(:,toto1(:,z),z);

Best Answer

You can check this using the debugger:
E.g.:
dbstop if error
Then run the code again. When Matlab stops at the error, check the dimensions:
size(VEC1(:,:,z))
size(eVects(:,toto1(:,z),z))
They will not match.