سؤال

How do I apply logical operators to a Matlab array in a "sum" fashion?

For example : and([1 0 0]) = 0, and([1 1 1]) = 1.

هل كانت مفيدة؟

المحلول

If you have:

a = [1,0,0]

then you can say:

any(a) %% which is equivalent to 'or'

all(a) %% which is equivalent to 'and'
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top