MATLAB: I want to create a matrix where each column is obtained by subtracting 1 from the previous column.

matrix manipulation

For example: A=[4 3 2 1 0; 3 2 1 0 -1; 1 0 -1 -2 -3]

Best Answer

Use a loop, repmat or bsxfun. e.g:
startcolumn = [4; 3; 1];
numcolumns = 5;
A = bsxfun(@minus, startcolumn, 0:numcolumns-1)