How to extend a row vector down in increasing values?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
TastyPastry
am 10 Sep. 2016
Beantwortet: Star Strider
am 10 Sep. 2016
Say I have the vector
a = [4 5 6];
How can I make the vector into
[4 5 6
5 6 7
6 7 8
7 8 9
...]
where each column increments by some constant amount? The number of initial values nor the number of new rows are constant.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 10 Sep. 2016
The bsxfun function is perfect for this:
a = [4 5 6];
N = 5; % Desired Row Lenth
Out = bsxfun(@plus, a, [0:N]')
Out =
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!