Cody

# Problem 44886. Given a Vector v1, create v2 which is the sum of each two adjacent elements in v1. {length(v2)=length(v1)-1}

Solution 3814003

Submitted on 24 Nov 2020 by Akrem Hadji
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
x = 1:10; y_correct = 3:2:19; assert(isequal(sumEachPair(x),y_correct))

o = 3 o = 3 5 o = 3 5 7 o = 3 5 7 9 o = 3 5 7 9 11 o = 3 5 7 9 11 13 o = 3 5 7 9 11 13 15 o = 3 5 7 9 11 13 15 17 o = 3 5 7 9 11 13 15 17 19

2   Pass
x = [1:100]'; y_correct = [3:2:199]'; assert(isequal(sumEachPair(x),y_correct))

o = 3 o = 3 5 o = 3 5 7 o = 3 5 7 9 o = 3 5 7 9 11 o = 3 5 7 9 11 13 o = 3 5 7 9 11 13 15 o = 3 5 7 9 11 13 15 17 o = 3 5 7 9 11 13 15 17 19 o = 3 5 7 9 11 13 15 17 19 21 o = 3 5 7 9 11 13 15 17 19 21 23 o = 3 5 7 9 11 13 15 17 19 21 23 25 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 o = 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Column 30 61 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 31 61 63 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 32 61 63 65 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 33 61 63 65 67 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 34 61 63 65 67 69 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 35 61 63 65 67 69 71 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 36 61 63 65 67 69 71 73 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 37 61 63 65 67 69 71 73 75 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 38 61 63 65 67 69 71 73 75 77 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 39 61 63 65 67 69 71 73 75 77 79 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 40 61 63 65 67 69 71 73 75 77 79 81 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 41 61 63 65 67 69 71 73 75 77 79 81 83 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 42 61 63 65 67 69 71 73 75 77 79 81 83 85 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 43 61 63 65 67 69 71 73 75 77 79 81 83 85 87 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 44 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 45 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 46 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 47 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 48 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 49 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 50 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 51 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 30 through 52 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 o = Columns 1 through 29 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43...

### Community Treasure Hunt

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

Start Hunting!