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 CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by