How to copy an array with some left-over indicies also added on?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tyler
am 3 Mai 2016
Beantwortet: Azzi Abdelmalek
am 3 Mai 2016
I have the following vector I would like to copy:
a = [1;2;3;4;5]
I would like my resulting vector to be
b = [1;2;3;4;5;1;2;3;4;5;1;2;3;4;5;1;2;3]
Where it is [a] 3 times repeated, and then repeats the next 3 indicies of [a], but not the whole vector. The repmat command will not allow me to repeat it by anything other than an integer. Is there a way to specify how many more indicies I want without having to do it manually?
Thanks!
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 3 Mai 2016
You can use repmat
a = [1;2;3;4;5]
b=[repmat(a,3,1); a(1:3)]
0 Kommentare
Weitere Antworten (2)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations 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!