Professional Documents
Culture Documents
System Package) and EISPACK (Eigen System Package) Projects - MATLAB Is A High
System Package) and EISPACK (Eigen System Package) Projects - MATLAB Is A High
Now, we are interested in doing some simple calculations. We will assume that
you have sufficient understanding of your computer under which MATLAB is
being run.
(>>) in the Command Window.
For example, let's suppose you want to calculate the expression, 1 + 2 * 3. You
type it at the prompt command (>>) as follows,
>> 1+2*3
ans =
7
(if you do not specify an output variable, MATLAB uses a default variable ans)
You may assign a value to a variable
>> x = 1+2*3
x=
7
Here x can be used further calculation >> 4*x
Ans =28
variable name = a value (or an expression)
where expression is a combination of numerical values, mathematical operators,
variables, and function calls. On other words, expression can involve:
1) manual entry
2) built-in functions
3) user-defined functions
If you do not wish to see the intermediate results, you can suppress the numerical
output by putting a semicolon (;) at the end of the line.
Eg >> t = 5;
>> t = t+1
Error message
>> x = 10;
>> 5x
Expression :
The Expression is the valid combination of operators and operands.
Operators are one which perform the operation and the operands are
one on which the operation is performed.
e..g. 2*4+5 is an expression .
Operators are * and + , and Operands are 2,4 and 5.
Types of Operators
===================
(i) Arithmatic Operators
(ii) Relational Operators
(iii) Logical Operators
(iv) Assignment Operators
(v) Increament and Decreament Operator
Priority Of Operators
()
!
^
*,/,%
+,-
>,<,>=,<=
==,!=
&&
||
=
(d) Assignment Operator
The = operators is known as the Assignment Operators and it is used
to assign the value into the variable.
a=2 It will assign the value 2 into the variable a
a==2 It will compare whether the value stored in the variable a is
equal to 2 or not.
(e) Increament and Decreament Operators
++ opreator is known as Increament Operator and it is used to
increase the value of variable by 1.
There are two types of Increament Operators :
(i) Pre-Increament Operator
(ii) Post - Increament Operator