1

 Introducing Arrays in MATHCAD

2

 Review of Last Week
 Last Week’s Exercises
 This week’s Exercises
 Arrays, matrices & vectors
 Range Variables
 Data analysis
 File I/O

3

 Aims
 Structure of Course
 Assessment
 Recommended Reading
 Other Resources
 Stuff you should know already

4

 What has gone wrong ?
 MathCAD crashed
 MathCAD Error message
 Wrong dimensions for result
 Result looks wrong

5

 Often OLE related
 Room 112 especially
 Cut/Paste into sheet
 Don’t try editing drawings from MathCAD
 Try restarting mathCAD
 Sometimes logout/reboot
 Save work frequently

6

 MathCAD displays message & highlights part of worksheet.
 Press <f1> for more help on error

7

 Not defined
 Everything must be defined before being used
 Left>Right, Top>Bottom
 Check spelling, font etc. carefully
 Illegal Context
 Using function name instead of variable – missing brackets
 Used a range variable in wrong place

8

 Put Correct units in placeholder
 MathCAD inserts other units to fit

9

 If still wrong, then problem with:
 Initial variables
 Formulae used in calculations
 Did you redefine a unit ?

10

 Define & use units like any other variable

11

 Check units for problem
 Debug worksheet
 Examine intermediate results
 Use RHS of sheet
 Try other inputs
 Boundary conditions
 Zero Threshold (10^{15} by default)

12

 Equations in physics given in general form
 Need to translate for specific problem

13


14


15

 Way of storing related data
 Experimental Results
 Coefficients
 Solutions to DEs
 3D position/velocity/force

16

 Vector – 1dimensional
 Matrix – 2dimensional
 Array – general term, covers both

17

 Matrix toolbar has tools to:
 Create and
 Operate on matrices
 Many functions f(x) operate on matrices

18

 Same for defining ordinary variable
 Follow : with
 [:::] from toolbar
 <ctrlm>
 InsertMatrix
 Dialog box for rows & columns

19


20


21

 mean(V)
 stdev(V)
 min(V), max(V)
 Etc, etc….

22

 Can plot 2 vectors of the same size against each other.
 Good for experimental data

23

 slope(Vx,Vy)
 intercept(Vx,Vy)
 Calculate best straight line fit
 Stderr(Vx,Vy) gives goodness of fit

24

 Subscripts to refer to elements
 Column operator
 Submatrices
 Can use any of these to either:
 Read variable (RHS)
 Set variable (LHS)

25

 Matrix Subscript allows access to individual elements
 Available the [ key
 Different from Text_{Subscripts}

26

 Subscripts start at 0 by default
 Can change but please don’t
 Vector have a single subscript
 V_{i}
 Matrices have two subscripts
 M_{r,c}

27


28

 Column address operator M^{<>}
 From keyboard or toolbar
 Very useful with experimental data from file

29


30


31


32


33


34


35

 Take on a series of values
 Define using semicolon [;]

36

 Restrictions on where used
 ‘illegal context’ error message
 Useful for filling arrays

37

 Define RV
 Use RV in array index & expression

38

 Use RV to step through array doing operation on each element

39

 Like using RV to do operation on each element of array
 More Efficient
 No need to define RV

40

 Can create RVs with different step sizes.
 Enter first 2 values separated by comma [,] before typing [;]

41

 Calculus palette
 2 forms
 Plain => defines local RV
 Range Variable => uses existing RV
 Summation & Iterated Product

42

 ORIGIN gives index of first element of arrays
 Usually 0, but sometimes changed
 last(v) gives index of last element of vector

43

 Uses ORIGIN & last() with summation operator & vector index

44


45


46

 Arrays, Vectors & Matrices as storage
 Create & populate arrays (units)
 Simple maths
 Plot experimental data
 Simple analysis
