Cody

# Problem 43675. Weave two matrices together to form one matrix

Solution 1875189

Submitted on 16 Jul 2019 by Brandon Suit
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   Pass
a = [1 2 3 4]; b = [5 6 7 8]; y_correct = [1 5 2 6 3 7 4 8]; assert(isequal(merge(a,b),y_correct))

c = 1 c = 1 5 2 c = 1 5 2 6 3 c = 1 5 2 6 3 7 4

2   Pass
a = 1:2:10; b = 2:2:10; y_correct = 1:10; assert(isequal(merge(a,b),y_correct))

c = 1 c = 1 2 3 c = 1 2 3 4 5 c = 1 2 3 4 5 6 7 c = 1 2 3 4 5 6 7 8 9

3   Pass
a = ones(1,5); b = 2*ones(1,5); y_correct = repmat([1 2],[1,5]); assert(isequal(merge(a,b),y_correct))

c = 1 c = 1 2 1 c = 1 2 1 2 1 c = 1 2 1 2 1 2 1 c = 1 2 1 2 1 2 1 2 1

4   Pass
a = [1 2 3; 4 5 6]; b = [4 5 6; 7 8 9]; y_correct = [1 4 2 5 3 6; 4 7 5 8 6 9]; assert(isequal(merge(a,b),y_correct))

c = 1 c = 1 4 2 c = 1 4 2 5 3 c = 1 4 2 5 3 6 4 0 0 0 0 0 c = 1 4 2 5 3 6 4 7 5 0 0 0 c = 1 4 2 5 3 6 4 7 5 8 6 0

5   Pass
a = ones(3); b = eye(3); y_correct = [1 1 1 0 1 0; 1 0 1 1 1 0; 1 0 1 0 1 1]; assert(isequal(merge(a,b),y_correct))

c = 1 c = 1 1 1 c = 1 1 1 0 1 c = 1 1 1 0 1 0 1 0 0 0 0 0 c = 1 1 1 0 1 0 1 0 1 0 0 0 c = 1 1 1 0 1 0 1 0 1 1 1 0 c = 1 1 1 0 1 0 1 0 1 1 1 0 1 0 0 0 0 0 c = 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 c = 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0