Returns one of two expressions depending on a condition.
(test) : (expression1) : (expression2)
test: Any Boolean expression.
expression1: A function handle called if test is true.
expression2: A function handle called if test is false.
Example
>> a = (2 > 1) : (@() 1) : (@() 2)
a =
1
>> a = (1 > 2) : (@() 1) : (@() 2)
a =
2
The colon.m you submitted will be moved to the class folder @function_handle:
mkdir @function_handle movefile submission/colon.m @function_handle
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers12
Suggested Problems
-
Remove any row in which a NaN appears
8771 Solvers
-
502 Solvers
-
Project Euler: Problem 7, Nth prime
1753 Solvers
-
"Low : High - Low : High - Turn around " -- Create a subindices vector
583 Solvers
-
Determine if input is a Narcissistic number
217 Solvers
More from this Author8
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Good idea to write matlab code as the other language like c.
Maybe I just don't have the matlab skills for this problem, but maybe the test suite is broken which makes it impossible to solve:
%%mkdir @function_handle
The test suite has been fixed. (The initial line is no longer commented out.)
Another problem in the test suite? The 2nd line in the test suite:
movefile submission/colon.m @function_handle
gives an error:
The function colon is a built-in MATLAB function. Please use a different function name.
Fixed.