MATLAB Answers

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

2 views (last 30 days)
KOOKMIN UNIV
KOOKMIN UNIV on 10 May 2016
Answered: Guillaume on 10 May 2016
For example: A=[4 3 2 1 0; 3 2 1 0 -1; 1 0 -1 -2 -3]

  0 Comments

Sign in to comment.

Accepted Answer

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

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.