Cody

# Problem 44446. Add a vector to a matrix

Solution 1528655

Submitted on 14 May 2018 by OZ FEDERMAN
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

2   Pass
mat = ones(2); v = 1:3; comb_correct = [1 1 inf; 1 1 inf; 1 2 3]; assert(isequal(addVecToMat(mat, v), comb_correct))

a = 3 b = 2 c = 2 d = 1 e = Inf Inf f = 1 1 Inf 1 1 Inf comb = 1 1 Inf 1 1 Inf 1 2 3

3   Pass
mat = ones(3, 4); v = [2 3]; comb_correct = [ones(3,4); 2 3 -inf -inf]; assert(isequal(addVecToMat(mat, v), comb_correct))

a = 2 b = 3 c = 4 ans = logical 1 k = 2 g = -Inf -Inf n = 2 3 -Inf -Inf comb = 1 1 1 1 1 1 1 1 1 1 1 1 2 3 -Inf -Inf

4   Pass
mat = ones(2); v = [2 3]; comb_correct = [1 1; 1 1; 2 3]; assert(isequal(addVecToMat(mat, v), comb_correct))

a = 2 b = 2 c = 2 comb = 1 1 1 1 2 3

5   Pass
mat = ones(3); v = 1:6; comb_correct = [repmat([ones(1,3) inf(1,3)], 3, 1); 1:6]; assert(isequal(addVecToMat(mat, v), comb_correct))

a = 6 b = 3 c = 3 d = 3 e = Inf Inf Inf Inf Inf Inf Inf Inf Inf f = 1 1 1 Inf Inf Inf 1 1 1 Inf Inf Inf 1 1 1 Inf Inf Inf comb = 1 1 1 Inf Inf Inf 1 1 1 Inf Inf Inf 1 1 1 Inf Inf Inf 1 2 3 4 5 6

### Community Treasure Hunt

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

Start Hunting!