I’m looking for Matlab equivalent of c# condition ? true-expression : false-expression conditional assignment. The most I know of is a = 5>2, which is true\false assignment,
but is there any one line conditional assignment for
if condition a=1;else a=2; end?
I’m looking for Matlab equivalent of c# condition ? true-expression : false-expression conditional assignment.
Share
One line conditional assignment:
This is an example of logical indexing,
a > 5is a logical (i.e. Boolean or binary) matrix/array the same size asawith a1where ever the expression was true. The left side of the above assignment refers to all the positions inawherea>5has a1.Etc…you can do pretty much anything you’d expect with such logical arrays.