Cody

Problem 2012. Tony's trick for duplicating an mx1 vector n times

Solution 1693095

Submitted on 15 Dec 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
x=magic(3); n=3; y_correct=[8 8 8; 3 3 3; 4 4 4]; assert(isequal(reproduce_nv(x,n),y_correct))

Unable to perform assignment because the size of the left side is 3-by-2 and the size of the right side is 3-by-1. Error in reproduce_nv (line 2) v(:,2:n)=v(:,1) Error in Test1 (line 4) assert(isequal(reproduce_nv(x,n),y_correct))

2   Fail
x=magic(10); n=19; y_correct=repmat(x(:,1),1,19); assert(isequal(reproduce_nv(x,n),y_correct))

Unable to perform assignment because the size of the left side is 10-by-18 and the size of the right side is 10-by-1. Error in reproduce_nv (line 2) v(:,2:n)=v(:,1) Error in Test2 (line 4) assert(isequal(reproduce_nv(x,n),y_correct))

3   Fail
x=1; n=0; y_correct=linspace(x,x,n); %arbitrary way to get the soln assert(isequal(reproduce_nv(x,n),y_correct))

v = 1

Output argument "ans" (and maybe others) not assigned during call to "reproduce_nv". Error in Test3 (line 4) assert(isequal(reproduce_nv(x,n),y_correct))

4   Fail
x='1'; n=7; y_correct=['1' '1' '1' '1' '1' '1' '1']; assert(isequal(reproduce_nv(x,n),y_correct))

v = '1111111'

Output argument "ans" (and maybe others) not assigned during call to "reproduce_nv". Error in Test4 (line 4) assert(isequal(reproduce_nv(x,n),y_correct))

Community Treasure Hunt

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

Start Hunting!