Cody

# Problem 1041. Find Index of maximum Value and maximum Value of a vector

Solution 1946823

Submitted on 23 Sep 2019
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
seq=randi(5,1,10); seq_max = max(seq); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

Error using max MAX with two matrices to compare and two output arguments is not supported. Error in max_val_idx (line 2) [M,I]=max(x,1) Error in Test1 (line 4) [max_val, max_idx] = max_val_idx(seq);

2   Fail
seq=rand(10); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

Error using max MAX with two matrices to compare and two output arguments is not supported. Error in max_val_idx (line 2) [M,I]=max(x,1) Error in Test2 (line 4) [max_val, max_idx] = max_val_idx(seq);

3   Fail
seq=randn(10); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

Error using max MAX with two matrices to compare and two output arguments is not supported. Error in max_val_idx (line 2) [M,I]=max(x,1) Error in Test3 (line 4) [max_val, max_idx] = max_val_idx(seq);

4   Fail
seq=randi(2^15,128,1); seq_max = max(seq(:)); seq_idx= find(seq==seq_max,1,'first'); [max_val, max_idx] = max_val_idx(seq); assert(isequal(max_val,seq_max)); assert(isequal(max_idx,seq_idx));

Error using max MAX with two matrices to compare and two output arguments is not supported. Error in max_val_idx (line 2) [M,I]=max(x,1) Error in Test4 (line 4) [max_val, max_idx] = max_val_idx(seq);