Embedded Communications in Wireless Sensor Network

Download Report

Transcript Embedded Communications in Wireless Sensor Network

Chapter 5:
MuPAD Objects I
Numbers, Identifiers, Expressions
MATLAB
for Scientist and Engineers
Using Symbolic Toolbox
You are going to



See that MuPAD handles objects
Get to know MuPAD numbers, identifiers and
expression types
Use these objects for various purposes
2
Domain Types


Every MuPAD object belongs to some data
type, called the domain type.
Domain Types




MuPAD Kernel: DOM_INT, DOM_RAT, etc.
MuPAD Language: Dom::Matrix(R), etc
User Defined Types
Identifying Domain Types
3
Fundamental Domain Types
4
Fundamental Domain Types (cont.)
5
Operands: op and nops

A MuPAD object can be
decomposed into operands.
Functions for accessing operands.

Accessing sub-operands

6
Operands: Example

Accessing specific operands
7
Operands: Nested Lists


Object:
Operands and sub-operands
8
Exercise

The following call of solve returns a set:
Extract the value of the solution for y and
assign it to the identifier y.
Solution:
9
Numbers

Number Data Types

Accessing Components
10
Numbers (cont.)

Integral Quotient and Remainder

Number? Not a Number!
11
Functions & Operators for Numbers
12
Exercise
 



Compute the decimal expansions of
and

163
3
with a precision of 10 and 100 digits,
e
respectively.

What is the 234th digit after the decimal point
of  ?
13
Exercise

After you execute x:= 10^50/3.0, only the
first DIGITS decimal digits of x are
guaranteed to be correct.
a.
Truncating the fractional part via trunc is
therefore questionable. What does MuPAD do?
b.
What is returned for x after increasing DIGITS?
14
Identifiers


Identifiers are names such as x or f that may
represent variables and unknowns.
DOM_IDENT
15
_assign and assign

The operator := is
a short form of
the system function
_assign.

assign: sets or lists
of equations are
transformed into
assignments:
16
Identifier Concatenation

Concatenation operator “.”
17
Exercise

Read the help page for solve. Solve the
system of equations
x1 + x2 = 1, x2 + x3 = 1, . . . , x19 + x20 = 1, x20 = π
in the unknowns x1, x2, . . . , x20.
Read the help page for assign and assign the
values of the solution to the unknowns.
18
Symbolic Expressions

An object containing symbolic terms
Number of Operands
Top Level Operator
19
Expression Tree

Graphical Representation of Expression
op(f,0)
=
+
op(f,[1,0])
0
op(f,2)
op(f,[1,1,0])
sin
*
x
g
x
0.3
op(f,[1,3])
?
1/5
y
op(f,[1,2,1,2])
20
21
22
System Functions vs. Operators

They are equivalent

Variable number of arguments

Operators are converted into system
functions internally.
23
Sequence and Range

$ and ..
Sequence Operator
Range Operator

Used with other operators
 1  2  3  ...  100
 1 2  3  ... 10
24
Mapping a Function

Applies a function to all operands of a
MuPAD object.
Function
Concatenation Operator
Use Back-ticks for
Operator Symbols
25
Operator Priorities

Higher priority operators apply first

Example
26
Key Takeaways

Now, you are able to



use op() and nops() to access operands of
MuPAD objects,
draw an expression tree for an expression,
tell how to use the following system functions and
operators.
dom_type
_mult
.
$
delete
..
op
map
assign
_sum
nops
27
Notes
28