Cody

# Problem 2836. Modify subscripts - easier

Solution 2542788

Submitted on 13 Jun 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   Fail
% first some basic tests A = 1; B = sub_double(A); y = B(1); y_correct = 1; assert(isequal(y,y_correct))

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test1 (line 4) y = B(1);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test2 (line 5) y = B([1 3],[3 1]);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test3 (line 5) y = B([1 3],[3 end]);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test4 (line 5) y = B(1,[3 1]);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test5 (line 5) y = B(2:end);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test6 (line 3) y = B([1 5 4 3 2],[3 4 5 1 2]);

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

Output argument "out" (and maybe others) not assigned during call to "sub_double/subsref". Error in Test7 (line 5) y = B(rows,cols);