Does MATLAB's optimizer perform common subexpression elimination on MATLAB code? For example:
if max(val) > minVal && max(val) < maxVal
maxVal = max(val)
end
How often is max(val)
evaluated there? Does it make sense to store the intermediate value in a temporary variable (assuming the repeated calculation is expensive) or does MATLAB handle this automatically?