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

3 vues (au cours des 30 derniers jours)
For example: A=[4 3 2 1 0; 3 2 1 0 -1; 1 0 -1 -2 -3]

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by