Cody

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

Solution 1819249

Submitted on 18 May 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   Pass
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));

max_val = 5 max_idx = 6

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

max_val = 0.9456 0.8048 0.9769 0.7944 0.9881 0.9530 0.8408 0.9737 0.9714 0.9213 max_idx = 2

Assertion failed.

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

max_val = 1.1706 0.8479 0.6908 0.9847 1.0579 0.5385 1.5636 0.5103 2.5288 1.2293 max_idx = 7

Assertion failed.

4   Pass
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));

max_val = 32763 max_idx = 22