MATLAB: Speeding up IF and comparisons whithin a loop

comparisonif statementloop

I have a function which is being run inside a loop.
The line consuming more time is an IF condition. X is not even a vector, just a single value.
if (ge(X, 0.557893) && le(X,1))
....
end
(The condition is equivalent to X>= 0.557893 && X<=1.)
Do you know why? Is there any equivalent and faster way to do it?
IF.PNG

Best Answer

Do not take the output of the profiler too literally. If this is the first access to the value of X, it might be the time for copying the value from the slow RAM to the fast processor cache. Only if you consider the surrounding code, the meaning of the profiled times become more or less meaningful.
The general idea would be to vectorized the code, I guess.