0% found this document useful (0 votes)
105 views6 pages

Introduction To The MATLAB

MatLap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views6 pages

Introduction To The MATLAB

MatLap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.

 
Introduction to the MATLAB
1- Introduction
MATLAB, which stands for MATrix LABoratory, is a technical computing environment
forhigh-performance numeric computation and visualization. Furthermore, MATLAB is a
modern programming language environment: it has sophisticated data structures, contains
built-in editing and debugging tools, and supports object-oriented programming. These factors
make MATLAB an excellent tool for teaching and research.
The basic building block in MATLAB is the matrix. The fundamental data type is the array.
Vectors, scalars, real and complex matrices are all automatically handled as special cases of
basic arrays. The built-in functions are optimized for vector operations. Thus, vectorized
commands or codes run much faster in MATLAB (vectorization is a way of computing in
which an operation is performed simultaneously on a list of numbers rather than sequentially on
each member of the list).

2- Starting MATLAB

On a Microsoft Windows platform, to start MATLAB, double-click the MATLAB


shortcut icon on your Windows desktop. After starting MATLAB, the MATLAB desktop opens
When you start MATLAB, a special window called the MATLAB desktop appears. The
desktop is a window that contains other windows. The major tools within or accessible from the
desktop are:
-The Command Window:- This window allows a user to enter simple commands; i.e (Use the
Command Window to enter variables and run functions and M-files).
-The Command History :- Lines you enter in the Command Window are logged in the
Command History window. In the Command History, you can view previously used functions,
and copy and execute selected lines.
-The Workspace:- All variables used in the current MATLAB session are saved in the
Workspace. You can view the content of the Workspace by clicking on File in the toolbar and
next selecting Show Workspace from the pull-down menu.

  1
 
MATLAB
AB ENGINEE
EERING // SSECOND YEAR//CHEM
YE EMICAL ENG
NG. DEPT.
 
-Thee Current D Directory::- MATLA AB file opperations use
u the currrent direcctory and the
t searchh path
as reeference ppoints. Anyy file you
u want to rrun must either be in the currrent direcctory or on
o the
searcch path.
A qu uick way tto view orr change the
t currennt directoryy is by ussing the Cu
Current Dirrectory fieeld in
the desktop
d tooolbar as shhown belo
ow.

-Thee Help Brrowser:- To


T view the
t onlinee documen ATLAB Heelp from Help
ntation, seelect MA
menu
u or MAT
TLAB Hellp directly
y in the Coommand Window.
W The
T preferrred metho
od is to usse the
Help
p Browserr. The Heelp Browsser can bee started by selectiing the ? icon from
m the dessktop
toolb
bar. On thee other haand, inform
mation aboout any co
ommand iss availablee by typing
g
>> help
h Comm
mand

For example
e U
Use on-linne help to request innfo on a sp
pecific fun
nction
>> help
h sqrt
-Thee Start buttton.
The MATLA AB Startt button providess easy access
a to tools, ddemos, shortcuts,
s and
docu
umentationn.

The MA
ATLAB deesktop on your com hich contaiins the proompt (>>) in the
mputer, wh
Com
mmand Winndow. Usuually, therre are 2 tyypes of pro
ompt:
>> fo
or full verrsion
EDU
U> for eduucational version
v

  2
 
MATLAB
AB ENGINEE
EERING // S ECOND YEAR//CHEM
YE EMICAL ENG
NG. DEPT.
 

  3
 
MATLAB
AB ENGINEE
EERING // SSECOND YEAR//CHEM
YE EMICAL ENG
NG. DEPT.
 
3- Qu
uitting MA
ATLAB

To end
e your M
MATLAB
B session, select Exxit MATL
LAB from the File m
menu in the
t desktoop, or
type quit in thee Commannd Windo
ow.

Main
n toolbar in Matlaab

1- File Meenu:- conssist of man


ny optionss that use to
t make many
m jobs such as saaving; prinnting
the proggram and etc
e

2- Edit Meenu:- in thhis menu you


y find thhe commaands of copy, paste, cut, find; etc but thhere
are threee importannt commaand and theese comm
mand:-
Clear Com
mmand Winndow
Clear Com
mmand Hisstory
Clear Woorkspace

3- Debug M
Menu:- thhis menu use
u to treaatment thee data.
4- Desktop
p Menu:- this menu use to coontrol the Main win
ndow of m
matlab programmingg

  4
 
MATLAB
AB ENGINEE
EERING // SSECOND YEAR//CHEM
YE EMICAL ENG
NG. DEPT.
 

Notee:- Move a tool outside of thee desktop by clickin


ng the und
dock buttoon in
n the tool’ss title
bar.
5- Window w Menu:- In this menu yoou can move m from
m the diffe
ferent win
ndows succh as
commannd windoww.

Usin
ng MATL
LAB as a calculator
c r

As an examplee of a simpple interacctive calcuulation, ju


ust type thee expressioon you waant to evalluate.
Let'ss start at the veryy beginnin ng. For eexample, let's supp pose youu want to calculatee the
expression, 1 + 2 * 3. You
Y type itt at the proompt comm mand (>>) as follow ws,

>> 1++2*3
ans =
7
MATLA
AB uses a default variable
v anns, short fo
or answer, to store tthe resultss of the cuurrent
calcu
ulation. N
Note that the
t variable ans is created (o
or overwritten, if itt is alread
dy existedd). To
avoid
d this, youu may assiign a value to a variiable or ou
utput argument nam
me. For exaample,
>> x = 1+2*3
x=
7
will result in x being giiven the value
v 1 + 2 £ 3 = 7.. This variiable nam
me can alw
ways be ussed to
referr to the ressults of thee previouss computaations. Theerefore, co
omputing 44x will ressult in

>> 4*x
4
ans =
28.0000
2
The followingg table givees the parttial list off arithmeticc operatorrs.
 

  Operato
ors and Sp
pecial Characters
+ Pluss; additionn operator..
- Minnus; subtraaction operrator.
* Scallar and maatrix multiiplication operator.
.* Arraay multipllication op
perator.
^ Scallar and maatrix exponentiationn operator..
.^ Arraay exponeentiation operator.
\ Leftt-division operator.
/ Righht-divisionn operatorr.
.\ Arraay left-divvision operrator.
./ Arraay right-diivision operator.

  5
 
MATLAB ENGINEERING // SECOND YEAR//CHEMICAL ENG. DEPT.
 
: Colon; generates regularly spaced elements and represents an entire row or
( ) l
Parentheses; encloses function arguments and array indices; overrides
[ ] Brackets; enclosures array elements.
. Decimal point.
… Ellipsis; line-continuation operator.
, Comma; separates statements and elements in a row.
; Semicolon; separates columns and suppresses display.
% Percent sign; designates a comment and specifies formatting.
_ Quote sign and transpose operator.
._ Nonconjugated transpose operator.
= Assignment (replacement) operator.

  6
 

You might also like