I want to create a matrix where each column is obtained by subtracting 1 from the previous column.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
KOOKMIN UNIV
am 10 Mai 2016
Beantwortet: Guillaume
am 10 Mai 2016
For example: A=[4 3 2 1 0; 3 2 1 0 -1; 1 0 -1 -2 -3]
0 Kommentare
Akzeptierte Antwort
Guillaume
am 10 Mai 2016
Use a loop, repmat or bsxfun. e.g:
startcolumn = [4; 3; 1];
numcolumns = 5;
A = bsxfun(@minus, startcolumn, 0:numcolumns-1)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!