repeat an element in a vector

1 回表示 (過去 30 日間)
Sehoon Chang
Sehoon Chang 2020 年 3 月 27 日
編集済み: Birdman 2020 年 3 月 27 日
Hi all,
I have one vector and i wish to repeat the first element of the vector once at the very beginning.
For example:
n = [1 2 3 4 5 6 7 8 9]
to
n = [1 1 2 3 4 5 6 7 8 9]
Thank you all.
  1 件のコメント
Sriram Tadavarty
Sriram Tadavarty 2020 年 3 月 27 日
how about using
n = [n(1) n];

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

採用された回答

Birdman
Birdman 2020 年 3 月 27 日
編集済み: Birdman 2020 年 3 月 27 日
[n(1) n]
or
[repmat(n(1),1) n]

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by