LOGICAL OPERATORS IN MATLAB
NAME:- PINKI KUMARI
ROLL NO.:-21303128
BRANCH:- CSE(B)
SUBJECT:- IT WORKSHOP
SUBMITTED TO:- MR. SAURABH
MAHAJAN
LOGICAL OPERATORS IN MATLAB
•There are mainly 3 logical operators in
MATLAB.
•AND,OR and NOT.
•The symbols &, |, and ~ are the logical array
operators AND, OR, and NOT.
•They work element-by-element on arrays.
• 0 represents logical false (F), and anything
nonzero represents logical true (T).
LOGICAL OPERATORS IN MATLAB
• The logical operators return a logical array with
elements. set to true (1) or false (0), as
appropriate.
• It returns 1 when the result is true, and returns 0
when the result is false.
•The & operator does a logical AND, the | operator
does a logical OR, and ~A complements the
elements of A.
LOGICAL OPERATORS IN MATLAB
•The precedence for the logical operators is-
•Logical operators with their equivalent function-
LOGICAL OPERATORS IN MATLAB
•Some basic operations-
LOGICAL AND (&)
•A & B performs a logical AND of
arrays A and B and returns an array
containing elements set to either logical 1
(true) or logical 0 (false).
•An element of the output array is set to
logical 1 (true) if both A and B contain a
nonzero element at that same array location.
•Otherwise, the array element is set to 0.
LOGICAL AND (&)
For example:-
LOGICAL OR (|)
•A | B performs a logical OR of
arrays A and B and returns an array
containing elements set to either logical 1
(true) or logical 0 (false).
•An element of the output array is set to
logical 1 (true) if either A or B contain a
nonzero element at that same array location.
•Otherwise, the array element is set to 0.
LOGICAL OR (|)
For example:-
LOGICAL NOT (~)
•~A returns a logical array of the same size
as A.
•The array contains logical 1 (true) values
where A is zero and logical 0 (false) values
where A is nonzero.
•not(A) is an alternate way to execute ~A.
• It enables operator overloading for classes.
LOGICAL NOT (~)
For example:-

logical operators.pptx

  • 1.
    LOGICAL OPERATORS INMATLAB NAME:- PINKI KUMARI ROLL NO.:-21303128 BRANCH:- CSE(B) SUBJECT:- IT WORKSHOP SUBMITTED TO:- MR. SAURABH MAHAJAN
  • 2.
    LOGICAL OPERATORS INMATLAB •There are mainly 3 logical operators in MATLAB. •AND,OR and NOT. •The symbols &, |, and ~ are the logical array operators AND, OR, and NOT. •They work element-by-element on arrays. • 0 represents logical false (F), and anything nonzero represents logical true (T).
  • 3.
    LOGICAL OPERATORS INMATLAB • The logical operators return a logical array with elements. set to true (1) or false (0), as appropriate. • It returns 1 when the result is true, and returns 0 when the result is false. •The & operator does a logical AND, the | operator does a logical OR, and ~A complements the elements of A.
  • 4.
    LOGICAL OPERATORS INMATLAB •The precedence for the logical operators is- •Logical operators with their equivalent function-
  • 5.
    LOGICAL OPERATORS INMATLAB •Some basic operations-
  • 6.
    LOGICAL AND (&) •A& B performs a logical AND of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false). •An element of the output array is set to logical 1 (true) if both A and B contain a nonzero element at that same array location. •Otherwise, the array element is set to 0.
  • 7.
  • 8.
    LOGICAL OR (|) •A| B performs a logical OR of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false). •An element of the output array is set to logical 1 (true) if either A or B contain a nonzero element at that same array location. •Otherwise, the array element is set to 0.
  • 9.
  • 10.
    LOGICAL NOT (~) •~Areturns a logical array of the same size as A. •The array contains logical 1 (true) values where A is zero and logical 0 (false) values where A is nonzero. •not(A) is an alternate way to execute ~A. • It enables operator overloading for classes.
  • 11.