2. • TYPE as it is in Command Line :
r=1; Chk result
r<=.5
( Result is 0)
and then at last
r>=.5
( Result is 1)
Now Enter the Following statement :
r = 1:5;
r<=3
U get 11100 as statement is true for first 3 elements
3. • 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)
5. • What was the Funda ???
y>0 returns a logical vector with ones where sin(x)
is positive as y>0 means it is checked element
by element if it is >0 ; and if it is not then it
returns 0.
After this we multiply by y to get the graph
7. • Use Logical Vector to replace zero with eps.
What is eps?
• This MATLAB function returns the difference
between 1.0 and the next largest number which
can be represented in MATLAB, i.e.
approximately 2.2e-16.
10. • Logical Functions :
x is a vector :
Try these statements :
x=1:5
any(x)
any(x) : returns scalar 1 in ans if any element of x
is nonzero.
11. • 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