Cody

Solution 1191418

Submitted on 17 May 2017 by Andrew Newell
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
% first some basic tests A = 1; B = sub_double(A); y = B(1); y_correct = 1; assert(isequal(y,y_correct))

2   Pass
A = [1 2 3 4 5 6 7 8 9]; B = sub_double(A); y = B([1 3],[3 1]); y_correct = [3 7]; assert(isequal(y,y_correct))

3   Pass
A = [1 2 3 4 5 6 7 8 9]; B = sub_double(A); y = B([1 3],[3 end]); y_correct = [3 9]; assert(isequal(y,y_correct))

4   Pass
A = [1 2 3 4 5 6 7 8 9]; B = sub_double(A); y = B(1,[3 1]); y_correct = [3 1]; assert(isequal(y,y_correct))

5   Pass
A = [1 2 3 4 5 6 7 8 9]; B = sub_double(A); y = B(2:end); y_correct = [4 7 2 5 8 3 6 9]; assert(isequal(y,y_correct))

6   Pass
A = magic(5); B = sub_double(A); y = B([1 5 4 3 2],[3 4 5 1 2]); y_correct = [1:5]; assert(isequal(y,y_correct))

7   Pass
A = magic(7); B = sub_double(A); rows = randi(7,1,10); cols = randi(7,1,10); y = B(rows,cols); y_correct = arrayfun(@(R,C)A(R,C),rows,cols); assert(isequal(y,y_correct))