Cody

# Problem 44496. vector indexes for a matrix

Solution 1742195

Submitted on 4 Mar 2019 by Athi
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
M = [1 2 3; 4 5 6; 7 8 9]; P = [1 2 3]; Q= [1 2 3]; y_correct = [1,5,9]; assert(isequal(Matrix_VectorIndexes(M,P,Q),y_correct))

2   Pass
M = [2 5 8; 3 6 9; 4 7 10]; P = [1 3 2]; Q = [1 1 2]; y_correct = [2,4,6]; assert(isequal(Matrix_VectorIndexes(M,P,Q),y_correct))

3   Pass
M = [1 5 4; 7 9 6; 8 2 3]; P = 1:3; Q = 3:-1:1; y_correct = [4,9,8]; assert(isequal(Matrix_VectorIndexes(M,P,Q),y_correct))

4   Pass
M = [1 5 4; 7 9 6; 8 2 3]; P = reshape(repmat((1:3)',[1,3]),[1,9]); Q = reshape(repmat(1:3,[3,1]),[1,9]); y_correct = M(:)'; assert(isequal(Matrix_VectorIndexes(M,P,Q),y_correct))

5   Pass
M = [1 5 4 2; 7 9 6 1; 8 2 3 5]; P = [2,1,3,2]; Q = 1:4; y_correct = [7,5,3,1]; assert(isequal(Matrix_VectorIndexes(M,P,Q),y_correct))