Repeating elements in a vector

1 次查看(过去 30 天)
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