我想将多个二维逻辑变量相互比较。我可以考虑用循环解决这个问题,但我怀疑它可以用内置函数完成。
我是否需要额外的功能,还是可以使用内置功能实现?
代码:
a=logical(randi([0 1],5,5));
b=logical(randi([0 1],5,5));
c=logical(randi([0 1],5,5));
%d,e,f... etc.
and(a,b,c)
然而,这会给您一个错误:
Error using &
Too many input arguments.
工作循环解决方案:
%example function to solve this
function out=extended_and(varargin)
out=varargin{1};
for ind=2:numel(varargin)
out=out & varargin{ind};
end
end
答案 0 :(得分:4)
如果dependencies {
/* Room dependencies */
/* You need to add those so Android will add Room to your project */
/* After that you can use all the annotations Room provide */
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
implementation 'android.arch.persistence.room:rxjava2:1.0.0-alpha5'
,a
,b
(c
,d
,e
)都相关,则它们应该相同阵列。类似的东西:
f
然后您可以使用L(:,:,1)=logical(randi([0 1],5,5));
L(:,:,2)=logical(randi([0 1],5,5));
L(:,:,3)=logical(randi([0 1],5,5));
%L(:,:,4)... etc.
%or, more simply:
% L = logical(randi([0 1], 5, 5, 327)); or however may arrays you want
:
all
如果您 拥有R = all(L, 3);
,a
,b
,......您可以先将它们连接起来:
c