필터 지우기
필터 지우기

Creating a vector with duplicate points after point 1

조회 수: 1 (최근 30일)
Brian
Brian 2011년 11월 17일
Hello, thanks for reading this.
I want to create a vector which the first point is 1, and then each point after is a duplicate, as in:
1 2 2 3 3 4 4 5 5 etc
There is probably a easier way to do this than what I imagine; what would you recommend?
Thanks

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 11월 17일
variant
n=7;
out = [1 reshape(ones(2,1)*(2:n),1,[])]
variant 2
out = ones(1,2*n-1)
out(2:2:end) = 2:n
out(3:2:end) = 2:n

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variant Inline Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by