필터 지우기
필터 지우기

Generate a vector like [5,4,4,3,3​,3,2,2,2,2​,1,1,1,1,1​]

조회 수: 3 (최근 30일)
Izan Segarra
Izan Segarra 2019년 2월 19일
댓글: Guillaume 2019년 2월 20일
How can I generate a vector like [5,4,4,3,3,3,2,2,2,2,1,1,1,1,1] without a loop?
  댓글 수: 5
Izan Segarra
Izan Segarra 2019년 2월 19일
I have used this code: odds = repelem([5,4,3,2,1],[1:5]);
It's just what I was looking for. Thank you.
Guillaume
Guillaume 2019년 2월 20일
The square brackets are unnecessary.
odds = repelem(5:-1:1, 1:5)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by