Cody

# Problem 44446. Add a vector to a matrix

Solution 3319428

Submitted on 21 Oct 2020
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   Fail
mat = ones(2); v = 1:3; comb_correct = [1 1 inf; 1 1 inf; 1 2 3]; assert(isequal(addVecToMat(mat, v), comb_correct))

Error: File: addVecToMat.m Line: 7 Column: 18 Invalid syntax for calling function 'size' on the path. Use a valid syntax or explicitly initialize 'size' to make it a variable. Error in Test2 (line 4) assert(isequal(addVecToMat(mat, v), comb_correct))

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

Error: File: addVecToMat.m Line: 7 Column: 18 Invalid syntax for calling function 'size' on the path. Use a valid syntax or explicitly initialize 'size' to make it a variable. Error in Test3 (line 4) assert(isequal(addVecToMat(mat, v), comb_correct))

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

Error: File: addVecToMat.m Line: 7 Column: 18 Invalid syntax for calling function 'size' on the path. Use a valid syntax or explicitly initialize 'size' to make it a variable. Error in Test4 (line 4) assert(isequal(addVecToMat(mat, v), comb_correct))

5   Fail
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))

Error: File: addVecToMat.m Line: 7 Column: 18 Invalid syntax for calling function 'size' on the path. Use a valid syntax or explicitly initialize 'size' to make it a variable. Error in Test5 (line 4) assert(isequal(addVecToMat(mat, v), comb_correct))

### Community Treasure Hunt

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

Start Hunting!