Download presentation

Presentation is loading. Please wait.

Published byRonnie Bloodsworth Modified over 2 years ago

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

2
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

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

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

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

6
Exercise Generate the sequence 6

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

8
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

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

10
Lists - Sort Numerical Values or Strings Min and Max 10

11
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

12
Lists – Function Summary 12

13
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

14
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

15
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

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

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

18
Sets – Function Summary 18

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

20
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

21
Functions How to define functions 21 -> represent mapping

22
Function – Composition @ - Composition Operator 22

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

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

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

26
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

27
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

28
Notes 28

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google