Embed presentation
Download to read offline


![• Vectors are compared element by element
and the resulting vector is called as Logical
Vector. It is one of the most power concepts in
MATLAB.
• For eg try this :
a=1:5;
b=[0 2 3 5 6];
a==b % no semicolon (Result is :
0 1 1 0 0)](https://image.slidesharecdn.com/logicalvectors-120429132928-phpapp02/85/Logical-vectors-3-320.jpg)







![• Try for the o/p of
x = [ 0 0]
any(x)
all(x)
Returns scalar 1 if all elements of vector x r non
zero!
x=1:5;
all(x)
Try to get info abt all logic functions](https://image.slidesharecdn.com/logicalvectors-120429132928-phpapp02/85/Logical-vectors-11-320.jpg)







Logical vectors in MATLAB compare elements of vectors and return a logical vector with the same size where each element indicates whether the comparison is true (1) or false (0). Logical vectors can be used to create discontinuous graphs by multiplying a vector by a logical vector that filters out negative values. They can also avoid division by zero errors by replacing zeros with a small nonzero value like eps. Common logical functions for vectors include any(), which returns 1 if any element is nonzero, and all(), which returns 1 only if all elements are nonzero.


![• Vectors are compared element by element
and the resulting vector is called as Logical
Vector. It is one of the most power concepts in
MATLAB.
• For eg try this :
a=1:5;
b=[0 2 3 5 6];
a==b % no semicolon (Result is :
0 1 1 0 0)](https://image.slidesharecdn.com/logicalvectors-120429132928-phpapp02/85/Logical-vectors-3-320.jpg)







![• Try for the o/p of
x = [ 0 0]
any(x)
all(x)
Returns scalar 1 if all elements of vector x r non
zero!
x=1:5;
all(x)
Try to get info abt all logic functions](https://image.slidesharecdn.com/logicalvectors-120429132928-phpapp02/85/Logical-vectors-11-320.jpg)





