Repeat Vector Values an Arbitrary Number of Times - MATLAB Cody - MATLAB Central

Problem 43739. Repeat Vector Values an Arbitrary Number of Times

  • Created by JD
Difficulty:Rate

Given two vectors of the same size, repeat the values of the first vector the number of times given in a second vector. For example:

x1=[1 2 3 4 5 6];
x2=[2 2 1 1 2 2];

then

out=[1 1 2 2 3 4 5 5 6 6];

Solution Stats

38.54% Correct | 61.46% Incorrect
Last Solution submitted on Jun 15, 2025

Solution Comments

Show comments

Problem Recent Solvers36

Suggested Problems

More from this Author11

Problem Tags

Community Treasure Hunt

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

Start Hunting!