Professional Documents
Culture Documents
Getting Started With Matlab: Fundamentals of MATLAB Different Windows of MATLAB
Getting Started With Matlab: Fundamentals of MATLAB Different Windows of MATLAB
1. 2.
SKNSCOE
SKNSCOE
Opening MATLAB in a lab: most computer on campus will have a direct shortcut on the desktop
SKNSCOE
Starting Matlab
When you start MATLAB, 4 windows appear (by default): MATLAB Command Window Current Directory Window Workspace Window Command History Window
SKNSCOE
To communicate with MATLAB program, use MATLAB command window. MATLAB display the prompt (>> ) to indicate that it is ready to receive instructions.
SKNSCOE
SKNSCOE
Workspace refers to the names and values of any variable in-use in the current work session.
SKNSCOE
All the previous keystrokes entered in Matlab Command Window showed here. You can click and drag the command into the Matlab command window or Matlab editor. You can alter the appearance of the desktop by clicking ViewDesktop layout.
SKNSCOE
Frame #2
Current Directory
Frame #3
Frame #1
The Command Window
Your Calculator Screen
This frame shows the files (excel, text, MATLAB files) that can immediately be used.
You can do exactly as on your calculator: add, subtract, divide, multiple, use parentheses to override the order of operations Later on, you will realize you can do a LOT more in this frame.
Frame #4
Command History
SKNSCOE
MATLAB Desktop
Current Directory
Command Window
History
SKNSCOE
Command History
SKNSCOE
General Setup
12
SKNSCOE
SKNSCOE
14
SKNSCOE
"DOCK IT"
15
SKNSCOE
16
SKNSCOE
17
SKNSCOE
Starting MATLAB on every machine usually leads to the prompt symbols >> in the command window
18
SKNSCOE
Try out this 3-line command in Matlab Command Window: >> x=[0:002:8]; >> y=5*sin(x); >> plot(x,y): When you put semicolon (;) at the end of your command line, Matlab will not shows the answer of your commands/expressions. Example of mathematical expressions in Matlab prompt: >> 8/10 ans = 0.8000 >> 5*ans ans = 4
SKNSCOE
Variables
A variable in MATLAB is a symbol used to contain a value. When we do not specify a variable name for a result, Matlab uses the symbol ans as a temporary variable containing the most recent answer.
SKNSCOE
Variables
Scalar arithmetic operations:
Operation Symbol ^ * / \ Exponentiation: ab Multiplication: ab Right division: a/b Left division: b/a MATLAB form a^b a*b a/b a\b
+ -
a+b a-b
Vectors / Array
>> a=[1 2 3 4] a= 1 >> a' ans = 1 2 3 4 2 3 4
SKNSCOE
SKNSCOE
SKNSCOE
Matrices
>> b=2.2*ones(4,4)
b=
2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000 2.2000
SKNSCOE
Reshape
>> a=[1:9] a= 1 2 3 4 5 6 7 8 9
>>
SKNSCOE
For
SKNSCOE
xy Plots
>> x=[1 3 6 8 10]; >> y=[0 2 1 3 1]; >> plot(x,y)
SKNSCOE