在这个表达中
lmin=lminflag & ~kmod & actminsub<nsm*pminu & actminsub>pminu;
Run Code Online (Sandbox Code Playgroud)
&运算符就像一个按位AND运算符?lminflag和kmod都是具有逻辑1或0作为元素的数组,并且lmin也变为1或0.
是.
& 是一个每元素AND运算符. && 是一个标量AND运算符,条件执行语句的其余部分.例如,给定:
a = true;
b = false;
aa = [true false];
bb = [true true];
fnA = @()rand>0.5; %An anonymous function returning true half the time
Run Code Online (Sandbox Code Playgroud)
然后:
a & b; %returns false
a && b; %returns false (same as above)
Run Code Online (Sandbox Code Playgroud)
然而
aa & bb; %this an error
aa && bb; %returns the array [true false]
Run Code Online (Sandbox Code Playgroud)
当操作数是函数时,它会更有趣,带有副作用.
b & fnA; %Returns false, and the `rand` function is called (including a small performance hit, and an update to the random state)
b && fnA; %Returns false, and the `rand` function was not called (since `b` is false, the actual value of `fnA` doesn;t effect the result
Run Code Online (Sandbox Code Playgroud)