Problem 46716. Matrix with increasing numbers (★★★★)
Solution Stats
Problem Comments
-
4 Comments
Your test suite detecting for loops is overzealous and trips up on arrayfun(..., "UniformOutput", false).
Fortunately, there is an abbreviation that can be used that will not be triggered by searches for "for": arrayfun(..., "Uni", 0). Incidentally, "Un" (or "un") can also be used while 0 is equivalent to false in this context. These abbreviations also work for cellfun.
Technically, arrayfun (cellfun as well) is just a loop in disguise. All in all, OP is asking for a vectorized solution.
@Dyuman You're right of course, but technically the problem description also says "do this without using loops, i.e. for/while not permitted", so arrayfun, cellfun and all the other kinds of fun that you can have with MATLAB are permitted. :)
Solution Comments
Show commentsProblem Recent Solvers30
Suggested Problems
-
Return the 3n+1 sequence for n
8276 Solvers
-
6660 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
378 Solvers
-
Change the first and last diagonal element of the identity matrix to zero
150 Solvers
-
463 Solvers
More from this Author52
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!