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.
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
Magic is simple (for beginners)
2954 Solvers
Find out total non zero element of matrix
196 Solvers
Pernicious Anniversary Problem
739 Solvers
290 Solvers
Given a square and a circle, please decide whether the square covers more area.
364 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!