Embedded Communications in Wireless Sensor Network
Download
Report
Transcript Embedded Communications in Wireless Sensor Network
Chapter 7:
MuPAD Objects III
Series, Table, Array, Matrix, Poly
MATLAB
for Scientist and Engineers
Using Symbolic Toolbox
You are going to
See that MuPAD handles objects
Get to know MuPAD series, tables, arrays,
matrices, and polynomial types
Use these objects for various purposes
2
Series Expansion
Taylor Series
Look at the differences!
Coefficient of a particular order
3
Series Expansion (cont.)
Laurent Series
4
Exercise #1
Besides the arithmetical operators, some
other system functions such as diff or int work
directly for series. Compare the result of
taylor(diff(1/(1-x), x), x) and the
derivative of taylor(1/(1-x), x).
Mathematically, both series are identical. Can
you explain the difference in MuPAD?
5
Exercise #2
The function
tends to zero
for large x, i.e.
Show that the approximation
is valid
for large values of x. Find better asymptotic
approximations of f.
6
Tables
Association of arbitrary indices with arbitrary
values
Index
Value
Explicit Table Generation
Implicit Table Generation
7
Tables – Accessing Elements
Use [ ] or _index( )
Check with contains( )
8
Tables - Operation
Getting the elements
Does this table have it on LHS or RHS?
9
Tables – Replacing and Removing
Current
Deleting
Replacing
10
Tables – select and split
Select rows which have 'a'.
Split table: has a, does not have a, unknown
11
Exercise #3
Generate a table T with the following entries:
Ford 1815, Reagan 4711, Bush 1234, Clinton 5678.
Look up Ford’s number. How can you find out
whose number is 5678?
12
Exercise #4
Generate the table T(1 = 1, 2 = 2, …, n = n) and
the list [1, 2, …, n] of length n = 100000. Add a
new entry to the table and to the list.
How long does this take?
Hint: the call time((a:= b)) returns the execution
time for an assignment.
13
Arrays
Multidimensional Data Structure
Integer Indices, Fixed Size
2D Array
3D Array
Starting index starts from 2!
Values
14
Arrays (cont.)
Values Only
Accessing Elements
Dimension Info: 0-th Operand
All Elements
15
Exercise
Generate a so-called Hilbert matrix H of
dimension 20 × 20 with entries
Hij = 1/(i + j − 1).
16
Vectors and Matrices
Generating matrices
Domain type. Default is Any Object.
17
Matrix Constructor
Dimension
Values
Value generating function
Sub-matrix range
18
Matrix Operation
Inverse Matrix
Matrix Concatenation
19
Matrix – System Functions
System Functions for Matrices
20
Matrix – System Functions (cont.)
System Functions for Matrices
21
Exercise
Hilbert Matrix
22
Matrix – Special Methods
23
Matrix Algebra
The Libraries linalg and numeric
Determinant
Eigenvalues
Transpose
Cholesky Decomposition
24
Exercise
Consider the following matrices:
Let BT be the transpose of B. Compute the
inverse of 2A + B BT .
25
Polynomials
26
Polynomials - Functions
System Functions for Polynomials
27
Polynomials – Functions (cont.)
System Functions for Polynomials
28
Polynomial - Manipulations
Evaluations
Integration and Differentiation
29
Exercise
Consider the polynomials p = x7 − x4 + x3 − 1
and q = x3 − 1.
Compute p − q2.
Does q divide p?
Factor p and q.
30
Key Takeaways
Now, you are able to
approximate an expression using Taylor and
Laurent series,
use MuPAD tables for key-value association
applications,
deal with fixed-size multi-dimensional data using
MuPAD arrays,
apply various linear algebraic functions on
MuPAD matrices,
and to manipulate MuPAD polynomials.
31
Summary
Explain the following expressions
taylor(sin(x),x=0,5)
has(T,b)
T[a]:= b
lhs(T)
select(T,has,x)
rhs(T)
contains(T,a)
op(T)
split(T,has,x)
A := array([[1,2],[x,y]])
M := matrix([[1,2],[x,y]])
delete T[a]
transpose(M)
op(A,0)
matrix::tr(M)
M[1,1..2]
linalg::det(M)
poly(a*x+b*x^2,[x],Dom::Integer
mapcoeffs(poly,_plus,2)
32