I have duly searched the documentation and SE, but have failed to find out the solution: given an arbitrarily large vector of boolean values, how to return e.g. the logical AND of given values?
I would expect something like:
and([1 1 1]) --> 1
(since true && true && true gives 1). Of course, it is not valid syntax.
My aim is to find the fastest way to compare two binary vectors of the same size and return 1 if they are identical and 0 if not. Since the element-wise and returns a vector if used on two vectors hence the title question.
Use all():
result = all(a == b);
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