필터 지우기
필터 지우기

Expanding Array as following;

조회 수: 1 (최근 30일)
도연 원
도연 원 2022년 9월 22일
댓글: 도연 원 2022년 9월 24일
Hi, I tried hard solution for this, but I think I can't... Would you please help?
I have logical vector here;
A=[1 0 0 1];
I want to expand this array like this, this is like expanding vector A by 3 times.
B=[1 1 1 0 0 0 0 0 0 1 1 1];
I tried function 'upsample', but it doesn't work as I intended like above.
Also made this logical values into 'double' and used interp1 function, also did not work.
Also searched in the Matlab Community, think that there is 100% matching question wharrich what I am seeking of...
Would you please help?
Thanks!

채택된 답변

Davide Masiello
Davide Masiello 2022년 9월 22일
편집: Davide Masiello 2022년 9월 22일
Try this
A = [1 0 0 1];
B = repelem(A,3)
B = 1×12
1 1 1 0 0 0 0 0 0 1 1 1
For more info see the documentation for repelem.
  댓글 수: 1
도연 원
도연 원 2022년 9월 24일
Actually I also need the case of repelem(A,5) or 10.
For the matter that I am having now, repelem makes a little bit easier.
Thanks Davide, and thanks for the Cris' too.

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

추가 답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 9월 22일
What about this?
A=[1 0 0 1];
B = [A;A;A];
B = B(:)'
B = 1×12
1 1 1 0 0 0 0 0 0 1 1 1

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by