100% found this document useful (1 vote)
112 views4 pages

Arithmetic and Logical Operators

The document discusses arithmetic and logical operators in MATLAB. It provides examples of evaluating expressions using addition, subtraction, multiplication, division and other arithmetic operators with variables assigned numeric values. It also provides examples of logical expressions using operators like AND, OR and NOT with variables assigned logical true and false values. The document explains that MATLAB treats non-zero values as logically true. Finally, it lists the hierarchy or order of precedence of operators in MATLAB.

Uploaded by

apecevsb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
100% found this document useful (1 vote)
112 views4 pages

Arithmetic and Logical Operators

The document discusses arithmetic and logical operators in MATLAB. It provides examples of evaluating expressions using addition, subtraction, multiplication, division and other arithmetic operators with variables assigned numeric values. It also provides examples of logical expressions using operators like AND, OR and NOT with variables assigned logical true and false values. The document explains that MATLAB treats non-zero values as logically true. Finally, it lists the hierarchy or order of precedence of operators in MATLAB.

Uploaded by

apecevsb
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Arithmetic operators:

1. The variables x,y,z have the values 2.5, 0.5, and 2 respetively. Evaluate the following
matlab expressions.
a. x+y+z
b. x*y*z
c. x/y
d. xy
e. xz
2. The complex variables are x=3-4i and y=1+2i. Evaluate the following Expressions
a. x+y
b. x-y
c. x*y
d. xy
3. Evaluate the fllowing ogical operations.
a) (a == 1) & (b == 2)
b) (a == 2) & (b == 2)
c) (a == 2) | (b == 2)
d) a & b
e) ~a
f) c = 0
g) ~c
h) (~b) | (~c)
4. Evaluate the program in matlab. And verify the result
a. number=3;
if (number == 1)
disp(The number is 1);
elseif (number == 2)
disp(The number is 2);
else
disp(The number is not 1 or 2);
end;
b. (number == 7) | (number == 11)

Expt.No.
Date:
Aim:

Arithmetic and Logical Operators

To know and understand the basic Arithmetic and logical operators in Matlab tool.
Softwares Required:
Matlab R2015a
Hardware Required:
A personnel Computer.
Procedures:
1.
2.
3.
4.

Open matlab File.


Type the program in the editor window.
Save the file with .m Extension and run the program.
Verify the output in the command Window.

Theory:
Arithmetic Operators: Performs arithmetic computations like addition, Subtraction ,
multiplication etc.

Logical Operators: Performs logical operators like AND,OR,NOT etc.


The operands for the logical operators need to be logical and can assume the values TRUE
expressed as 1 and FALSE expressed as 0. If the operand has numerical values, then
MATLAB takes non zero values as TRUE.

&
|
~
xor()
any()
all()

And
Or
Not
Exor
True if any element of vector is non-zero
True if all element of vector are non zero

Hierarchy of Operators:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Parenthesis ()
Transpose (.),Power (.^), Complex conjugate (), Matrix Power (^)
Unary plus (+),Unary minus (-), Logical NOR (~)
Multiplication (.*), Right Division (./),Left Division(.\), Matrix Multiplication (*),
Matrix right division (/),Matrix left division (\)
Addition (+), Subtraction (-)
Colon Operator (:)
Less than (<),Less than equal to (<=),Greater than (>),Greater than equal to(>=),equal
to (= =),Not equal to (=)
Logical AND (&)
Logical OR (|)

Result:

You might also like