copying the contents of a vector onto a longer vector

1 回表示 (過去 30 日間)
cgo
cgo 2022 年 7 月 25 日
回答済み: Chunru 2022 年 7 月 25 日
Let's say I have a vector a that is of size 4. I have a vector b of size 10. I want to copy the contents of vector a into b until it 'runs out'.
For example: if a = [1 2 3 4]; and b is a size 10 vector.
Then b = [1 2 3 4 1 2 3 4 1 2].
How do i do this?

採用された回答

Chunru
Chunru 2022 年 7 月 25 日
a = [1 2 3 4];
b = a(mod(0:9, 4)+1)
b = 1×10
1 2 3 4 1 2 3 4 1 2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by