Cody

# Problem 42984. Vector addition

Solution 1495404

Submitted on 17 Apr 2018 by Gareth Lee
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
filetext = fileread('vadd.m'); assert(isempty(strfind(filetext,'regexp'))) assert(isempty(strfind(filetext,'switch')))

2   Pass
v1 = [1 4]; v2 = [3 8 6 1]; v3_correct = [3 8 7 5]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

3   Pass
v1 = [9 9]; v2 = [9 9]; v3_correct = [1 9 8]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

4   Pass
v1 = [9 4 2 3 5 6 7 3 3 5 5 4 6 3 2 4 2 5 7 7 8 5 4 3 4 7 8 7]; v2 = [3 5 7 3 4 5 2 5 4 8 7 6 4 3 7 8 9 5 4 0 3 2 7 9 0 3 2 8 9]; v3_correct = [4 5 1 5 8 0 9 2 8 2 3 1 9 0 1 1 3 7 9 8 1 1 3 3 3 8 0 7 6]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

### Community Treasure Hunt

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

Start Hunting!