EXP - NO1 Introducction
EXP - NO1 Introducction
______________________________________________________________________________________________
Experiment No. 1
MATLAB
1-1 Introduction
➢ To start MATLAB from your Windows desktop, open the MATLAB shortcut icon
by double-click. You will know MALTAB is running when you see the special
symbol " » " prompt in the MATLAB Command Window.
➢ To end your MATLAB session, select Exit MATLAB from the File menu, or type
quit (or exit) in the Command Window, or with easy way by click on close button
in control box.
2- Command History: Statements you enter in the Command Window are logged in
the Command History. In the Command History, you can view previously run
statements, and copy and execute selected statements.
3- Current Directory Browser: MATLAB file operations use the current directory
reference point. Any file you want to run must be in the current directory or on the
search path.
(1 - 1)
University of Zakho Mechanical Engineering Department MATLAB Laboratory
______________________________________________________________________________________________
4- Workspace: The MATLAB workspace consists of the set of variables (named
arrays) built up during a MATLAB session and stored in memory.
Current Directory Browser Command Window
workspace
Command
History
Figure 1.1
Figure 1.2
(1 - 2)
University of Zakho Mechanical Engineering Department MATLAB Laboratory
______________________________________________________________________________________________
1-3 Basic Commands
• clc Command: Clears the Command window and homes the cursor.
• help Command: help <Topic> displays help about that Topic if it exist.
• lookfor Command: Provides help by searching through all the first lines of
MATLAB help topics and returning those that contains a key word you specify.
• edit Command: enable you to edit (open) any M-file in Editor Window. This
command doesn't open built-in function like, sqrt. See also type Command.
Notes:
• If a statement does not fit on one line, use "... ", followed by Enter to indicate that
the statement continues on the next line. For example:
>> S= sqrt (225) *30 /...
(20*sqrt (100)
• If we don't specify an output variable, MATLAB uses the variable ans (short of
answer), to store the last results of a calculation.
• Use Up arrow and Down arrow to edit previous commands you entered in
Command Window. .
• Insert "%" before the statement that you want to use it as comment; the statement
will appear in green color.
» clear a
Arithmetic operators
Operators Description
+ Plus
– Minus
* Matrix multiply
.* Array multiply
^ Matrix power
.^ Array power
\ Backslash or left matrix divide
/ Slash or right matrix divide
.\ Left array divide
./ Right array divide
() Specify evaluation order
Exercises
1- Use edit command to edit the plot function, and then try to edit sin function. State
the difference.
3- Enter x=2; a=25; z=11, then clear the variable z only and show the result of
y = ax + 4z
(1 - 4)