在Matlab数组上应用累加and运算符

在Matlab数组上应用累加and运算符,matlab,logic,and-operator,Matlab,Logic,And Operator,如何以“求和”的方式将逻辑运算符应用于Matlab数组 例如:and([100])=0,and([11])=1。如果您有: a = [1,0,0] 然后你可以说: any(a) %% which is equivalent to 'or' all(a) %% which is equivalent to 'and' 也可以用prod([100])表示“and”,用(sum([100])>0表示“or”,但我认为any()和all()更好

如何以“求和”的方式将逻辑运算符应用于Matlab数组

例如:and([100])=0,and([11])=1。

如果您有:

a = [1,0,0]
然后你可以说:

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

all(a) %% which is equivalent to 'and'
也可以用prod([100])表示“and”,用(sum([100])>0表示“or”,但我认为any()和all()更好