MATLAB: Generating A(i,j) = [i; j]

matrix generation

Hi, is there a clean way to generate a matrix A(i,j) = [i; j], especially without resorting to loops? Thank you so much!

Best Answer

You want each element of your matrix to be a two element vector?
That is not a matrix, but it does sound like a cell array.
C = num2cell(cumsum(ones(5),2));
C = cellfun(@(x,y) [x;y],C,C.','Un',0)