1. Once a command is typed and the Enter key is passed, the command is executed.
However, only the last command is executed. Everything executed previously is
unchanged.
2. Several commands can be typed in the same line. This is done by typing a comma
between the commands. When the Enter key is passed the commands are executed in
order from left to right.
a=
2
b=
3
c=
5
3. It is not possible to go back to previous line in the command window, make
correction, and the re-execute the command.
4. A previously typed a command can be recalled to the command prompt with up arrow
key ( . When the command is displayed at the command prompt, it can be modified
if need and executed. The down arrow key can be used to move down the
previously typed command.
5. The Semicolon (;):- when a command is typed in the command window and the
<enter> key is passed, the command is executed. Any output that the command
generates is displayed in the command window. If a semicolon is typed at the end of
the command the output of the command is not displayed. Typing a semicolon is
useful when the result is obvious or known, or when the output is very large.
7
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
If a several commands are typed in the same line, the output from any of the
commands will not be displayed if a semicolon is typed between the commands
instead of a comma.
6. Typing %:- when the (percent symbol%) is typed in the beginning of the commands
or between the command, this has no effect on the execution of the command (%
represented as a comment only).
7. clc:- clear the command window.
clear:- Remove the variables from memory.
6 exp(x) x
e ans= 2.2026 e+004
8
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
9
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
1.It may consist only of the letters a– z, the digits 0–9 and the underscore (_)., (can not
contain punctuation characters (eg. Period, comma, semicolon).
Example:
<enter>
z=3.000+4.000i
<enter>
ans=3
10
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
<enter>
ans=4
ans=5, where √
ans=5.000+7.000 i
Example:- translate the equation of angle in Matlab commands
( )
angle=0.9273
Exercises
1-Write a program to convert a given temperature from (F) to (C).
2- Write a program to calculate the vapor pressure of water according to Antoine equation
,A=18.3036,B=3816.44,C=-46.13
3- For the following distillation column. Write a code to find the value of steam B and the
composition of steam D? D=80 , % X?,%S?,%T?,%Z?
F=100kg
15% X
25%S
40%T
11
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
4- The distance (d) from a point (3,-4) from the line 2x-7y-10=0.(use the abs and sqrt
commands).
5- Calculate the following:-
√
( ) ( )
( )
( )
12