What is the best way to construct a matrix whose elements are exactly their indices in Matlab?
EDIT: The existing answers to this question is applicable to how
Another option using repmat (since the content of these matrices is redundant):
repmat
X=repmat((1:size(YourMatrix, 2))', 1, size(YourMatrix, 1)); Y=repmat(1:size(YourMatrix, 1), size(YourMatrix, 2), 1);