How can I make a vector of a repeating sequence

6 ビュー (過去 30 日間)
Anouk Heuvelmans
Anouk Heuvelmans 2018 年 3 月 21 日
コメント済み: Jan 2018 年 3 月 22 日
I want to make a vector with 40 repeats of [0 0 0 1] in a column so it would look like this: 0 0 0 1 0 0 0 1 (0 0 0 1)x40
How would I be able to make this?

採用された回答

Amjad Green
Amjad Green 2018 年 3 月 21 日
x=[0 0 0 1];n=length(x);k=1;j=1; for i=1:40 while j<=n y(k)=x(j); k=k+1; j=j+1; end j=1; end
  1 件のコメント
Anouk Heuvelmans
Anouk Heuvelmans 2018 年 3 月 21 日
Perfect, thanks a lot!

サインインしてコメントする。

その他の回答 (1 件)

David Fletcher
David Fletcher 2018 年 3 月 21 日
編集済み: David Fletcher 2018 年 3 月 21 日
repmat([0 0 0 1],1,40)
  1 件のコメント
Jan
Jan 2018 年 3 月 22 日
This is much more efficient than a loop.

サインインしてコメントする。

カテゴリ

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