Code:
if (round(xw(1))>2) & (round(xw(2))>2) & (round(xw(1))<h-1) & (round(xw(2))<w-1)
W0 = img(round(xw(1))-2:round(xw(1))+2,round(xw(2))-2:round(xw(2))+2);
else
NA=1;
break
endif
xw is a column vector which contains the co-ordinates of a point.
h and w are the dimensions of an image.
I am using these lines of codes in OCTAVE
But when I run the function which contains these lines I get a warning
warning: Matlab-style short-circuit operation performed for operator &
Is it that in spite of using &, octave is performing && operation?
I learnt that if I use && then depending on the first statement is True or False, the next statements are evaluated.
So, is this what is happening when I get this warning? What is the solution to this problem then?
I want to check if all the statements are True and not just the first one.
You can safely avoid the warning by using && operator instead.
The warning comes from the fact that Matlab has a special handling for & operators in this context:
When you use the element-wise & and | operators in the context of an if or while loop expression (and only in that context), they use short-circuiting to evaluate expressions.
For reasons of compatibility, Octave detects this behaviour and emulates what Matlab does. Note that its completely safe to use && also in Matlab since that is what is implicitly used anyways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With