Cody

# Problem 6. Select every other element of a vector

Solution 202051

Submitted on 8 Feb 2013 by Basto
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 = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = 0.1493 y = 0.1493 0.8407 y = 0.1493 0.8407 0.8143 y = 0.1493 0.8407 0.8143 0.9293 y = 0.1493 0.8407 0.8143 0.9293 0.1966

2   Pass
%% x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = 0.6160 y = 0.6160 0.3517 y = 0.6160 0.3517 0.5853 y = 0.6160 0.3517 0.5853 0.9172 y = 0.6160 0.3517 0.5853 0.9172 0.7572 y = 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 y = 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 y = 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 y = 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 y = 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Column 11 0.0119 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 12 0.0119 0.1622 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 13 0.0119 0.1622 0.3112 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 14 0.0119 0.1622 0.3112 0.1656 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 15 0.0119 0.1622 0.3112 0.1656 0.2630 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 16 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 17 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 18 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 19 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Column 21 0.0782 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 22 0.0782 0.1067 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 23 0.0782 0.1067 0.0046 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 24 0.0782 0.1067 0.0046 0.8173 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 25 0.0782 0.1067 0.0046 0.8173 0.0844 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 26 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 27 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 28 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 29 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Column 31 0.5499 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 32 0.5499 0.8530 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 33 0.5499 0.8530 0.3510 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 34 0.5499 0.8530 0.3510 0.4018 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 35 0.5499 0.8530 0.3510 0.4018 0.2399 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 36 0.5499 0.8530 0.3510 0.4018 0.2399 0.1839 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 37 0.5499 0.8530 0.3510 0.4018 0.2399 0.1839 0.4173 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 38 0.5499 0.8530 0.3510 0.4018 0.2399 0.1839 0.4173 0.9027 y = Columns 1 through 10 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 11 through 20 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 21 through 30 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 31 through 39 0.5499 0.8530 0.3510 0.401...

3   Pass
%% x = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away']; actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = A y = Ao y = Aog y = Aogi y = Aogie y = Aogieg y = Aogiegi y = Aogiegia y = Aogiegiaa y = Aogiegiaaa y = Aogiegiaaay y = Aogiegiaaaya y = Aogiegiaaayaf y = Aogiegiaaayafr y = Aogiegiaaayafrw y = Aogiegiaaayafrwy