Sei sulla pagina 1di 27

1

Chapter 1
Getting Started, Overview, and Environment
1.1 Start and Quit MATLAB 1.12 Binary File Input/Output
1.2 Entering Commands 1.13 Images and Sounds
1.3 Array Expressions 1.14 Flow Controls
1.4 Two-Dimensional Graphics 1.15 User-Defined Functions
1.5 MATLAB Scripts 1.16 Cell Arrays
1.6 Three-Dimensional Graphics 1.17 Structures
1.7 Symbolic Mathematics 1.18 Tables
1.8 Screen Text Input/Output 1.19 Graphical User Interfaces (GUI)
1.9 Text File Input/Output 1.20 GUIDE
1.10 Running Programs in Blocks 1.21 Creating Standalone Applications
1.11 Running Programs with Break Points 1.22 MATLAB On-Line Tutorials
2

1.1 Start and Quit MATLAB


Concepts
MATLAB desktop
Desktop layout
Current folder
Current folder window
Command window
Prompt
Workspace

Function
quit
3

1.2 Entering Commands

/s
m Concepts
y =
5
v0

g = 9.81 m/s 2 Statements (commands)


45

Assignment statements
=

x
variable = expression
Variable
Expression: constants
+variables+functions
+operators

Functions
cos
sin
pi
clear
clc
doc
4

1.3 Array Expressions

Concepts
Arrays
Vectors: 1-D arrays
Matrices: 2-D arrays
Row vectors, column vectors
Array creations: brackets, commas, and
colons
Operators
Element-wise operators
5

1.4 Two-Dimensional Graphics

Concepts Functions
Figure window plot
End of statements: title
commas and xlabel
semicolons ylabel
6

1.5 MATLAB Scripts

Concepts
Script
Editor window
Create/save/run script
Automatic syntax checking
Variable/function names
7

1.6 Three-Dimensional Graphics

Functions hold on
repmat zero
transpose () mesh
length colorbar
surf axis vis3d
8

1.7 Symbolic Mathematics


Functions
syms
solve
subs
simplify
matlabFunction
9

1.7 Symbolic Mathematics (Continued)


Live Editor
10

1.8 Screen Text Input/Output

Concepts Functions
Semicolons are used to separate rows in a matrix. input
Newline character (\n) fprintf
Format specification
11

1.8 Screen Text Input/Output (Continued)

How are the elements ordered in the memory?

Indexing to a Matrix
Subscript indexing
Linear indexing
12

1.9 Text File Input/Output

Functions
Concepts fopen
File identifier fclose
File access type fscanf
13

1.10 Running Programs in Blocks


Concepts
Blocks (sections)
Debug
14

1.11 Running Programs with Break Points


Concepts
Break points
Step
Continue
Quit Debugging
Evaluate Selection
15

1.12 Binary File Input/Output

Concepts Functions
Binary files save
MAT files load
16

1.13 Images and Sounds

Functions
imread
image
axis image
Concepts sound
figure
Search path path
17

1.14 Flow Controls

Concept
Flow-control statements

For-Loop
for var = vector
statements
end
18

1.15 User-Defined Functions

Concept
Main functions
Subfunctions (local functions)
Global variables
Blank lines

User-Defined Functions
function output-args = name(input-args)
statements
end
19

1.16 Cell Arrays


20

1.17 Structures

Concept
Structures
Structure Arrays
Continuation of Statements (...)
21

1.18 Tables
22

1.19 Graphical User Interfaces (GUI)


23

1.19 Graphical User Interfaces (Continued)


24

1.20 GUIDE: Graphical User Interface


Development Environment
25

1.20 GUIDE: Graphical User Interface


Development Environment (Continued)
26

1.21 Creating Standalone Applications


27

1.22 MATLAB On-Line Tutorials