How can I compare two logical vectors to a value?

25 ビュー (過去 30 日間)
jan
jan 2012 年 12 月 5 日
I want to do the following without loops:
logix = [1;0;0;1;1;1;0;0;0];
logiy = [0;1;1;0;1;0;0;1;1];
logi = zeros(size(logix,1),1);
for i = 1:size(logix,1)
if logix(i)==0
if logiy(i)==0
logi(i)=1;
else logi(i)=0;
end
else logi(i)=0;
end
end
logix and logiy are logical vectors (same size) and I want logi to be the vector that is 1 if logix and logiy are 0 in the same row or 0 if not. Thanks in advance, regards, jan

採用された回答

Arthur
Arthur 2012 年 12 月 5 日
logi = ~logix & ~logiy

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2012 年 12 月 5 日
編集済み: Jos (10584) 2012 年 12 月 5 日
or via De Morgan (<http://en.wikipedia.org/wiki/De_Morgan%27s_laws>)
logi = ~(logix | logiy)
  1 件のコメント
Jos (10584)
Jos (10584) 2012 年 12 月 5 日
stupid hyperlinks ...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by