Problem 44480. The average of the second largest values
Solution Stats
Solution Comments
-
1 Comment
John BG
on 23 Feb 2018
this
x2=x
[max1,ind1]=max(x2,[],2)
x2(sub2ind(size(x),[1:3],ind1'))=NaN
[max2,ind2]=max(x2,[],2)
y=mean(x2(sub2ind(size(x),[1:size(x,1)],ind2')))
solves the question yet the checker returns not a valid answer.
-
1 Comment
John BG
on 23 Feb 2018
the following 4 lines solve this question
[max1,ind1]=max(x,[],2)
x(sub2ind(size(x),[1:3],ind1'))=NaN
[max2,ind2]=max(x,[],2)
y=mean(x(sub2ind(size(x),[1:3],ind2')))
yet the online checker returns not a valid answer
Problem Recent Solvers43
Suggested Problems
-
Find the numeric mean of the prime numbers in a matrix.
7670 Solvers
-
Remove any row in which a NaN appears
7583 Solvers
-
3453 Solvers
-
Remove the two elements next to NaN value
515 Solvers
-
3377 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!