I have a function called f(x,y)
, which returns 1
when both x = -1
and y = 1
, and 0
otherwise.
I want to apply it on every pair of the same column elements of a matrix. I want to know if I have to repeat it the other way? or does it work the same for f(y,x)
? I mean does it return 1
if one of the elements is -1
and the other is 1
anyway or it has to be in order?
It depends on how the function f
is defined.
-1
and "the other" 1
, it would work without change for reverse inputs. -1
and "the second" must be 1
- the result might be different when the argument order is switched.For example, this is a "symmetric" way to define f
:
function out = f(x,y)
out = ~(x+y);
end
And this is an "asymmetric" way:
function out = f(x,y)
out = (x == -1) && (y == 1);
end