# Chapter 6: MuPAD Objects II Sequence, List, Set, Function MATLAB for Scientist and Engineers Using Symbolic Toolbox.

## Presentation on theme: "Chapter 6: MuPAD Objects II Sequence, List, Set, Function MATLAB for Scientist and Engineers Using Symbolic Toolbox."— Presentation transcript:

Chapter 6: MuPAD Objects II Sequence, List, Set, Function MATLAB for Scientist and Engineers Using Symbolic Toolbox

You are going to See that MuPAD handles objects Get to know MuPAD sequences, lists, sets, and function types Use these objects for various purposes 2

Sequences A series of MuPAD objects separated by commas. Concatenation Just Numbers and Repeats 3

Sequences (cont.) Range using in Application: Repeated differentiation Manipulation 4 Apply to all operands Modify 1 st Object Delete 2 nd Object

Exercise Assign the values x1=1, x2=2,..., x100=100 to the identifiers x1, x2,..., x100. 5

Exercise Generate the sequence 6

Exercise Use a simple command to generate the double sum Hint: the function _plus accepts arbitrarily many arguments. Generate a suitable argument sequence. 7

Lists – DOM_LIST An ordered sequence of arbitrary MuPAD objects enclosed in square brackets Parallel Assignment 8 Swap Two. assignments happen at the same time Two. assignments happen at the same time

Lists – Substitute, Concatenate Substitution may make the list longer. List Concatenation 9

Lists - Sort Numerical Values or Strings Min and Max 10

Lists – Other Operations 11 Returns TRUE if the element has it as an operand. Returns TRUE if the element has it as an operand. TRUE FALSE UNKNOWN L1L2

Lists – Function Summary 12

Exercise Generate two lists with the elements a, b, c, d and 1, 2, 3, 4, respectively. Concatenate the lists. Multiply the lists pairwise. 13

Exercise Multiply all entries of the list [ 1, x, 2 ] by 2. Suppose you are given a list, whose elements are lists of numbers or expressions, such as [[1, x, 2], [PI], [2/3, 1]], how can you multiply all entries by 2 ? 14

Exercise Let X = [x1,..., xn] and Y = [y1,..., yn] be two lists of the same length. Find a simple method to compute their “inner product” x1 y1 + · · · + xn yn, You can achieve this by using zip, _plus, map and appropriate functions 15

Sets – DOM_SET An unordered sequence of arbitrary objects enclosed in curly braces Basic Operations 16

Sets – Other Operations map / contains / select / split 17

Sets – Function Summary 18

Exercise How can you convert a list to a set and vice versa? 19

Exercise Instead of the binary operators intersect and union, you can also use the corresponding MuPAD functions _intersect and _union to compute unions and intersections of sets. These functions accept arbitrarily many arguments. Use simple commands to compute the union and the intersection of all sets belonging to M: M := {{2, 3}, {3, 4}, {3, 7}, {5, 3}, {1, 2, 3, 4}}: 20

Functions How to define functions 21 -> represent mapping

Function – Composition @ - Composition Operator 22

Functions - Operations Expression and Functions Operations 23 Evaluate and assign Differentiation

Exercise Define the functions f(x) = x 2 and g(x) =. Compute f (f (g(2)) and f(f(... f (x)...)). 24 100 times

Exercise Define a function that reverses the order of the elements in a list. 25

Key Takeaways Now, you are able to generate sequences using a range operators, manipulate lists, apply basic operations on sets, and to define/derive functions using @ operators. 26

Summary Explain the following expressions 27 \$ 10..20 x \$ 3 [a,b] := [b,a] list1.list2 sort(list) min(list) max(list) select(list,has,x) split(list,has,x) zip(list1,list2,_plus,x) map(set1,sin) set1 union set2 f @ g f @@ 3

Notes 28

Download ppt "Chapter 6: MuPAD Objects II Sequence, List, Set, Function MATLAB for Scientist and Engineers Using Symbolic Toolbox."

Similar presentations