You are on page 1of 6

Applied Mathematics Laboratory

Asian Institute of Technology


Handout 1
1
Tue 7 Sep 2010
1 Course Objectives and Outlines
This course aims to provide students with basic programming skills in using the MATLAB
software. The instructions will be based on 15 weekly tutorial/laboratory sessions as
tentatively listed below.
1. Familiarization with MATLAB
Working at the command prompt
Basic arithmetic commands
Basic array and matrix manipulations
Basic statistical analysis
Computation with complex numbers
2. Using functions, script les, and input/output les
Creating functions
Writing script les to perform a series of tasks
Saving data to les and loading data from les
Project: Comparing data from dierent les
3. Relational operators and control ows
Logical operators
if, for, and while statements
Debugging in MATLAB
Project: Computing the moving average, maximum, and minimum
4. Signal generation and function plotting: Part one
Basic functions, e.g. trigonometric, logarithmic, and exponential
Plotting one-variable functions
Conguring plot appearances
Creating multiple subplots
Project: Plotting hyperbolic functions
5. Signal generation and graph plotting: Part two
Plotting discrete-time signals
1
Prepared by Poompat Saengudomlert, Asian Institute of Technology.
1
Basic signal processing commands
Plotting two-variable functions using three-dimensional plots or countour lines
Exporting plots as image les
Project: Lowpass ltering of signals
6. Graph representations and basic properties
Matrix representations of graphs
Computing node degrees
Number of paths between node pairs
Checking for connectedness
Project: Finding Euler paths in connected graphs
7. Graph algorithms
Computing minimum spanning trees
Dijkstra algorithm for shortest path routing
Finding link-disjoint paths
Project: Computing the average internodal distances of graphs
8. Review for mid-semester examination
9. Recursion
Writing recursive functions
Computing factorials
Computing Fibonacci numbers
Project: Solving the tower-of-Hanoi problem
10. Searching and sorting
Divide-and-conquer approach in problem solving
Binary search in a sorted list
Merge sort
Project: Parity check error control coding
11. Random number generator
Generating uniform random integers
Generating uniform random real numbers
Generating other types of random variables, e.g. Gaussian, exponential, bino-
mial, and Poisson
Project: Verifying the central limit theorem
12. Numerical analysis
2
Solving linear equations
Regression
Root nding
Project: Curve tting using polynomials
13. Numerical method
Numerical integration
Numerical dierentiation
Numerical solutions to ordinary dierential equations
Project: Finding impulse responses of electrical circuits
14. Grapical user interface (GUI)
Creating a tabular form for GUI
GUI with function plotting
GUI with geometric drawing
Project: Visualizing graph algorithms
15. Review for nal examination
2 Familiarization with MATLAB
After creating example arrays and matrices at the command prompt, you should try the
following commands.
2
Basic array information
size - Size of matrix.
length - Length of vector.
ndims - Number of dimensions.
numel - Number of elements.
disp - Display matrix or text.
isempty - True for empty matrix.
isequal - True if arrays are identical.
isnumeric - True for numeric arrays.
islogical - True for logical array.
logical - Convert numeric values to logical.
2
When you need additional information in MATLAB about a specic command, you can use the help
command. For example, you can type help size to nd out more about the size command. The lists
of all commands can be generated by typing help alone.
3
Elementary matrices
zeros - Zeros array.
ones - Ones array.
eye - Identity matrix.
repmat - Replicate and tile array.
rand - Uniformly distributed random numbers.
randn - Normally distributed random numbers.
: - Regularly spaced vector and index into matrix.
Matrix manipulation
reshape - Change size.
diag - Diagonal matrices and diagonals of matrix.
tril - Extract lower triangular part.
triu - Extract upper triangular part.
fliplr - Flip matrix in left/right direction.
flipud - Flip matrix in up/down direction.
flipdim - Flip matrix along specified dimension.
find - Find indices of nonzero elements.
end - Last index.
Special variables and constants
ans - Most recent answer.
realmax - Largest positive floating point number.
realmin - Smallest positive floating point number.
pi - 3.1415926535897....
i, j - Imaginary unit.
inf - Infinity.
NaN - Not-a-Number.
isnan - True for Not-a-Number.
isinf - True for infinite elements.
isfinite - True for finite elements.
Arithmetic operators
plus - Plus +
minus - Minus -
mtimes - Matrix multiply *
times - Array multiply .*
mpower - Matrix power ^
power - Array power .^
mldivide - Backslash or left matrix divide \
mrdivide - Slash or right matrix divide /
ldivide - Left array divide .\
rdivide - Right array divide ./
4
Special characters
colon - Colon :
paren - Parentheses and subscripting ( )
paren - Brackets [ ]
paren - Braces and subscripting { }
punct - Structure field access .
punct - Continuation ...
punct - Separator ,
punct - Semicolon ;
punct - Comment %
punct - Invoke operating system command !
punct - Assignment =
punct - Quote
transpose - Transpose .
ctranspose - Complex conjugate transpose
horzcat - Horizontal concatenation [,]
vertcat - Vertical concatenation [;]
Relational operators
eq - Equal ==
ne - Not equal ~=
lt - Less than <
gt - Greater than >
le - Less than or equal <=
ge - Greater than or equal >=
Logical operators
and - Logical AND &
or - Logical OR |
not - Logical NOT ~
xor - Logical EXCLUSIVE OR
any - True if any element of vector is nonzero
all - True if all elements of vector are nonzero
Set operators
union - Set union.
unique - Set unique.
intersect - Set intersection.
setdiff - Set difference.
setxor - Set exclusive-or.
ismember - True for set member.
5
Basic statistical analysis
max - Largest component.
min - Smallest component.
mean - Average or mean value.
median - Median value.
std - Standard deviation.
var - Variance.
sort - Sort in ascending order.
sortrows - Sort rows in ascending order.
sum - Sum of elements.
prod - Product of elements.
hist - Histogram.
histc - Histogram count.
cumsum - Cumulative sum of elements.
cumprod - Cumulative product of elements.
6

You might also like