Repeating elements in a vector

조회 수: 1 (최근 30일)
Furkan Sencer Kaçar
Furkan Sencer Kaçar 2023년 10월 20일
댓글: Furkan Sencer Kaçar 2023년 10월 20일
Hi, i want my following vector:
A = [0,1; 1; 5; 10; 20]
to be
A = [0,1; 1; 5; 10; 20;0,1; 1; 5; 10; 20;0,1; 1; 5; 10; 20; ... ]
(50 times repeated)

채택된 답변

Mahmoud
Mahmoud 2023년 10월 20일
편집: Mahmoud 2023년 10월 20일
A = [0; 1; 5; 10; 20]; % Vector declaration
B = repmat(A, 50, 1); % Replicate Fifty times

추가 답변 (1개)

William Rose
William Rose 2023년 10월 20일
A = [0,1; 1; 5; 10; 20]
is not valid because it uses a comma as well as semicolons. I assume you meant to write
A = [0; 1; 1; 5; 10; 20];
Then do
A=repmat(A,50,1);
Check:
size(A)
ans = 1×2
300 1
OK.

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by