MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Without using repmat, or for loop, or concatenation, create a function to duplicate a vector, v, a specified number of times, n. v can be numeric or character. n may be 0.

Examples

If

v = 5; n = 3;

then return v1:

v1 = [5 5 5]

If a 2d matrix is supplied then the vector v will be the first column.

V = magic(4); n = 4;

then v and v1 are returned as shown below.

v = [16 5 9 4]' v1 = [16 16 16 16; 5 5 5 5; 9 9 9 9; 4 4 4 4]

Hint: use indexing

34 correct solutions
21 incorrect solutions

Last solution submitted on Apr 16, 2015

2 Comments