Arithmetic and Logical Operators
Arithmetic and Logical 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:
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.
Theory:
Arithmetic Operators: Performs arithmetic computations like addition, Subtraction ,
multiplication etc.
&
|
~
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: