Wanting existing code to magically know what you want it to do is nice, but is hardly likely to be successful in general. Sometimes you get lucky, but usually, not so.
When diag is applied to a vector, it always produces a square matrix, even if it is specified as an off-diagonal by use of the second argument to diag. This can be useful behavior, since diag has often been used to build up banded matrices, as the sum of several diagonals created separately.
diag cannot know where the vector came from, that in this case, the vector was derived from a diag operation applied to a non-square matrix.
You can always delete the unwanted rows after the fact.
Best Answer