Download presentation
Presentation is loading. Please wait.
Published byElla Perkins Modified over 9 years ago
2
PH15010 Laboratory Techniques - An Introduction to MATHCAD
3
Introduction Review of last weekReview of last week Vector and Matrix MathsVector and Matrix Maths StatisticsStatistics Solving simultaneous equations with matricesSolving simultaneous equations with matrices
4
Review of Last Week Processing experimental data with arraysProcessing experimental data with arrays Adding Error bars to graphsAdding Error bars to graphs Pre-Processing DataPre-Processing Data –Convert to f –Logarithms for power law Extract slope & intercept from dataExtract slope & intercept from data
5
Functions Reviewed Take one or more inputs (parameters) and return a value or valuesTake one or more inputs (parameters) and return a value or values From f(x) toolbar if you don’t know the nameFrom f(x) toolbar if you don’t know the name Afunction(parameters)=Afunction(parameters)= Avariable:=Afunction(p1,p2,p3…)Avariable:=Afunction(p1,p2,p3…) Use the help system/f(x) dialogUse the help system/f(x) dialog
6
Matrix & Vector Maths Used for:Used for: –Processing experimental data –Statistics –Resolving forces etc in 2D, 3D –Co-ordinate transformations –Simultaneous Equations –Applying transforms to data
7
Creating Arrays in MathCAD 2 ways of entering arrays2 ways of entering arrays –Input Table (already encountered) Spreadsheet type entrySpreadsheet type entry Expand to fit data availableExpand to fit data available –Insert Matrix Dialog box Array of placeholdersArray of placeholders Good if you know how many elements in matrix/vectorGood if you know how many elements in matrix/vector
8
Creating an array with Insert|Matrix… Same for defining ordinary variableSame for defining ordinary variable Follow : withFollow : with –[:::] from toolbar – – –Insert|Matrix Dialog box for rows & columnsDialog box for rows & columns
9
Creating arrays with Insert|Matrix… Placeholders to fill in Can use units Empty 3 – element vector
10
Matrix Maths #1
11
Matrix Maths #2 (Symbolically) Matrix Multiplication Determinant Addition of constant
12
Matrix & Vector Maths Add, Multiply & Divide matrices/vectorsAdd, Multiply & Divide matrices/vectors Must have correct numbers of rows & columnsMust have correct numbers of rows & columns
13
Addressing Arrays with Indices Index addressing allows access to individual elements of arrayIndex addressing allows access to individual elements of array Examine & Set elementsExamine & Set elements Indices start at 0Indices start at 0 Indices use [ keyIndices use [ key 2D matrices use two indices for row, column selection2D matrices use two indices for row, column selection
14
Indices #1 Vector Example Simple 2 element vector Examine elements Set element 0 Result of setting
15
Indices #2 Matrix Example Sample matrix Examine elements Subscript too big Set element Result
16
Accessing Parts Of Arrays Index addressing – single elementIndex addressing – single element Column Extract operator M <>Column Extract operator M <> Submatrix() functionSubmatrix() function Transposing matricesTransposing matrices
17
The submatrix() function Define a matrix Use submatrix() to extract part of the array Matrix to operate on Rows Columns
18
Transpose Rows & Columns Uses M T operatorUses M T operator From matrix toolbarFrom matrix toolbar
19
Other matrix functions 1. Information Return information about:Return information about: –Size of matrix rows(M), cols(M), last(V), length(V)rows(M), cols(M), last(V), length(V) –Contents of matrix min(A), max(A)min(A), max(A) V V
20
Other matrix functions 2. Manipulation Create new arraysCreate new arrays –Put 2 arrays together stack(A1,A2)stack(A1,A2) augment(A1,A2)augment(A1,A2) –Sorting sort(V), reverse(A)sort(V), reverse(A) rsort(M,r), csort(M,c)rsort(M,r), csort(M,c)
21
Statistical Functions on Vectors #1 From f(x) dialog box under “Statistics”From f(x) dialog box under “Statistics” AveragingAveraging –mean() ‘Average value’ –median() ‘Half way item’ –mode() ‘Most common value’
22
Statistical Functions on Vectors #2 Variance & Standard DeviationVariance & Standard Deviation 2 forms of each2 forms of each Analysis of sampleAnalysis of sample –Stdev(), Var() Analysis of whole populationAnalysis of whole population –stdev(), var() Note capitalisationNote capitalisation
23
Vectorise Operator #1 From matrix toolbarFrom matrix toolbar Forces evaluation on element by element basisForces evaluation on element by element basis Overrides normal matrix mathsOverrides normal matrix maths –‘dot’ product –Determinant |M| –Powers M x
24
Vectorise Operator #2 Dot product With vectorise operator
25
Range Variables Take on a series of valuesTake on a series of values Define using semicolon [;]Define using semicolon [;]
26
Range Variables #2 Restrictions on where usedRestrictions on where used ‘illegal context’ error message‘illegal context’ error message Useful for filling arraysUseful for filling arrays
27
Filling Arrays using RVs Define RVDefine RV Use RV in array index & expressionUse RV in array index & expression
28
Processing Arrays using RVs Use RV in expressions to create output array from input arrayUse RV in expressions to create output array from input array
29
Range Variables with different step sizes Can create RVs with different step sizes.Can create RVs with different step sizes. Enter first 2 values separated by comma [,] before typing [;]Enter first 2 values separated by comma [,] before typing [;]
30
Summation #1 Summation operator on matrix paletteSummation operator on matrix palette Sum of all elements in a vectorSum of all elements in a vector
31
Summation #2 Operators on Calculus paletteOperators on Calculus palette Do summation on any expressionDo summation on any expression 2 forms2 forms –Plain => defines local RV –Range Variable => uses existing RV
32
Summation #3 Sum of first 5 integers Sum of elements 20-30 of vector Counts
33
Summation #4 Reciprocals of factorials 2 terms 4 terms 9 terms
34
Data Files Used Input table to put data into MathCAD by hand.Used Input table to put data into MathCAD by hand. Can use Import on input table to get from a file (makes a copy)Can use Import on input table to get from a file (makes a copy) –Select table & right-click Also can link to data file with File Read Component (preferred)Also can link to data file with File Read Component (preferred)
35
Reading Data Files #1 File Read ComponentFile Read Component Reads from datafile arrayReads from datafile array Text filesText files –Numbers separated by comma or tab Other formats supportedOther formats supported
36
Reading Data Files #2 Insert|Component…|File Read or WriteInsert|Component…|File Read or Write Wizard:Wizard: –(Select file type) –Browse for file –Finish Give name for arrayGive name for array
37
Reading Data Files #3 ExampleExample
38
This weeks worksheet Arrays & IndicesArrays & Indices Columns (Revision)Columns (Revision) Submatrix() functionSubmatrix() function Other array functionsOther array functions Reading data from fileReading data from file
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.