Last active
August 17, 2019 19:46
-
-
Save Thermoflux/d48e8bd7e48cf9e29561383e16eb01f6 to your computer and use it in GitHub Desktop.
A simple ifelse anonymous MATLAB function similar to R's ifelse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%ifelse - Single line ifelse alternative statement for Matlab. Its implemented as an anonymous function for low overhead. | |
%% This will only work for numerical values, Please use with caution. | |
ifelse = @(Condition,TrueVal,FalseVal) Condition .*TrueVal + ~Condition .*FalseVal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment