This problem was fun. I was able to find a better way to solve beat my own solution. Not the best way though. But lot better.
@Alireza yarmohammadi: your comment was deleted as it revealed an answer to the problem.
In response to the question you asked, though, your function returns m, which is not the complete answer. The last line in your function displays the correct result, but assigns it to ans, not m.
1126 Solvers
Generate a vector like 1,2,2,3,3,3,4,4,4,4
4290 Solvers
361 Solvers
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
304 Solvers
Area of an equilateral triangle
3055 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!