# How can I compare two logical vectors to a value?

56 views (last 30 days)
jan on 5 Dec 2012
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
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Arthur on 5 Dec 2012
logi = ~logix & ~logiy
##### 1 CommentShowHide None
jan on 5 Dec 2012
thx

Sign in to comment.

### More Answers (1)

Jos (10584) on 5 Dec 2012
Edited: Jos (10584) on 5 Dec 2012
or via De Morgan (<http://en.wikipedia.org/wiki/De_Morgan%27s_laws>)
logi = ~(logix | logiy)
##### 1 CommentShowHide None
Jos (10584) on 5 Dec 2012
stupid hyperlinks ...

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!

Translated by