37
Data in MathCAD

Data in MathCAD

Embed Size (px)

DESCRIPTION

Data in MathCAD. Data in tables. Tables are analogous to matrices The numbers of columns and rows can be dynamically changed (in contrast to matrix) To enter table: Menu: Insert/ Data /Table (MC v. 15) In placeholder type variable name which will be assigned to table - PowerPoint PPT Presentation

Citation preview

Page 1: Data in MathCAD

Data in MathCAD

Page 2: Data in MathCAD

Data in tables Tables are analogous to matricesTables are analogous to matrices The numbers of columns and rows can be dynamically The numbers of columns and rows can be dynamically

changedchanged (in contrast to matrix) (in contrast to matrix) To enter table:To enter table:

Menu: Insert/Menu: Insert/DataData/Table/Table (MC v. 15) (MC v. 15) In placeholder type variable name which will be In placeholder type variable name which will be

assigned to tableassigned to table In cells type the valuesIn cells type the values Each rows and columns must contains the same Each rows and columns must contains the same

number of data. If data are missing the value ‘0’ will number of data. If data are missing the value ‘0’ will be assignedbe assigned

Access to data in table is identicalAccess to data in table is identical to to matrix. matrix.

Page 3: Data in MathCAD

Data in tables

Page 4: Data in MathCAD

Data in tables RowRow/column/column appears appears in matrix in matrix when only 1 data is when only 1 data is

inserted into the cell:inserted into the cell: Matrix size = specified cell in the lowest row Matrix size = specified cell in the lowest row

and in last column and in last column Unfilled cells contains 0Unfilled cells contains 0 Once specified cell can not be removedOnce specified cell can not be removed!!

To overcome problem: create new matrix To overcome problem: create new matrix with correct number of rows with correct number of rows ii and columns and columns jj usingusing

jiji ,, OLDNEW

Page 5: Data in MathCAD

External data sources: Data in files

The most popular file formats accepted by The most popular file formats accepted by MathCAD:MathCAD: Text filesText files Excel worksheetsExcel worksheets

To insertTo insert text text file containing data: file containing data: Menu: Menu: Insert/Insert/DataData//File InputFile Input Chose file formatChose file format Browse Browse to to the file locationthe file location In the appeared placeholder type variable In the appeared placeholder type variable

name that will be assigned to the contents of name that will be assigned to the contents of filefile

Page 6: Data in MathCAD

Inserting the text file

Page 7: Data in MathCAD

Inserting the text file Changes in the text file locationChanges in the text file location

Page 8: Data in MathCAD

Inserting the Excel worksheets A range of Excel cells can be inserted into the A range of Excel cells can be inserted into the

MathCADMathCAD There can be more then one range in single There can be more then one range in single

insertioninsertion One variable is being assigned to one rangeOne variable is being assigned to one range All variables forms a vectorAll variables forms a vector Cells can contain numbers as well as text (in Cells can contain numbers as well as text (in

contrast to table and text filescontrast to table and text files, ver. 2001, ver. 2001)) Worksheets can be edited (double-click) using Worksheets can be edited (double-click) using

all Excel functions (object embeddedall Excel functions (object embedded - -Excel Excel has to be installed in systemhas to be installed in system))..

Page 9: Data in MathCAD

Inserting the Excel sheets

To insert worksheet:To insert worksheet: Menu: Insert/Component/ExcelMenu: Insert/Component/Excel Browse file or create newBrowse file or create new Choose number of ranges for input and output Choose number of ranges for input and output

((relatively to Excel worksheetrelatively to Excel worksheet). If no data have to ). If no data have to be inserted into thebe inserted into the Excel Excel worksheet type inputs worksheet type inputs number 0number 0

Type ranges corresponding to outputsType ranges corresponding to outputs – e.g. A1:B10 – e.g. A1:B10 ((ifif workworksheet name isheet name iss different from Sheet1 type different from Sheet1 type sheet namesheet name – e.g. Sheet4!A1:B10 – e.g. Sheet4!A1:B10))

In placeholder(s) type variable(s) In placeholder(s) type variable(s) Number of outputs/inputs and range of cells can be Number of outputs/inputs and range of cells can be

edited in properties of insertionedited in properties of insertion

Page 10: Data in MathCAD
Page 11: Data in MathCAD

MathCAD files as data source in MathCAD

MathCAD can use data included in other MathCAD MathCAD can use data included in other MathCAD filesfiles

Access to data is possible after embedding MathCAD Access to data is possible after embedding MathCAD file:file: menu: Insert/References, menu: Insert/References, Brows file on disc or type file addressBrows file on disc or type file address Below the insertion all data, definitions, Below the insertion all data, definitions,

assignment from inserted file are valid in the assignment from inserted file are valid in the present documentpresent document

Problem: Problem: matrix/vector elements numbers when matrix/vector elements numbers when array origin is changed. array origin is changed.

Page 12: Data in MathCAD
Page 13: Data in MathCAD

Data analysis and optimisation

ApproximationApproximation

Page 14: Data in MathCAD

definition

Approximation is a part of numerical Approximation is a part of numerical analysis. It is concerned with how functions analysis. It is concerned with how functions ff((xx) can be best approximated ) can be best approximated ((fittedfitted) ) with with another functions another functions FF((xx))

Page 15: Data in MathCAD

application Simplifying calculations when original Simplifying calculations when original

function function ff((xx) is defined by complicated ) is defined by complicated expression expression

designdesign of continuous dependency when of continuous dependency when function function ff((xx) is ) is describeddescribed on discrete set of on discrete set of arguments. arguments. If the form of approximating If the form of approximating function is given only values of function function is given only values of function parameters showing the best approximation parameters showing the best approximation have to behave to be determine. determine.

Page 16: Data in MathCAD

types of approximation

Interpolating approximationInterpolating approximation

Uniform approximationUniform approximation

Square-mean approximation Square-mean approximation

Page 17: Data in MathCAD

Interpolating approximation NeedNeedss to satisfy condition: function given to satisfy condition: function given ff((xx) and approximating function ) and approximating function FF((xx) have ) have the same values on the set of nodes and the same values on the set of nodes and (sometimes) the same values of derivatives (sometimes) the same values of derivatives ((if givenif given)) too. too.

1 1.5 2 2.5 3 3.5 410

20

30

40

50

60

7069

12

f a( )

z

41 a x

Page 18: Data in MathCAD

Uniform approximation

Function Function FF((xx) approximating function ) approximating function ff((xx) ) in the range [in the range [aa,,bb], satisfying condition], satisfying condition:: maximal residuum maximal residuum is set tois set to minimum minimum

Page 19: Data in MathCAD

Square-mean approximation

Approximating function is determined by Approximating function is determined by the use of condition:the use of condition:

Geometrically condition means: The area Geometrically condition means: The area between curves representing functions have between curves representing functions have to reach minimum. to reach minimum.

min2 dxxfxFEb

a

Page 20: Data in MathCAD

Condition for discreet set of arguments:Condition for discreet set of arguments:

min2

iii xfxFE

Square-mean approximation

Page 21: Data in MathCAD

Function:Function:

minimize(minimize(functionfunction, , pp1, 1, pp2,...)2,...)

can be used to determine parameters of can be used to determine parameters of approximating function minimizing the sum of approximating function minimizing the sum of square deviations between values given in the square deviations between values given in the table and calculated from the function.table and calculated from the function. functionfunction calculates the sum of square calculates the sum of square

deviations as a function of parameters.deviations as a function of parameters.pp1, 1, pp2 – parameters of approximating function2 – parameters of approximating function

Square-mean approximation in MathCAD

Page 22: Data in MathCAD

Approximating algorithm:Approximating algorithm:1.1. Insert data to be approximateInsert data to be approximate2.2. Build the approximating functionBuild the approximating function3.3. Create a counting variable with values Create a counting variable with values

from 0 to number of data minus 1from 0 to number of data minus 14.4. Build function that calculates sum of Build function that calculates sum of

square of deviations with parameters of square of deviations with parameters of approximating function as variablesapproximating function as variables

5.5. Assign starting values of parametersAssign starting values of parameters6.6. Use the function minimize.Use the function minimize.

Square-mean approximation in MathCAD

Page 23: Data in MathCAD
Page 24: Data in MathCAD

Advantageous of Advantageous of minimizeminimize function: function: simplesimple explicitexplicit suitable for any approximating functionsuitable for any approximating function ccan be used in optimisation problem an be used in optimisation problem

solvingsolving

Page 25: Data in MathCAD

Other MathCAD tools for approximation

Page 26: Data in MathCAD

genfit

Syntax:Syntax:c:=genfit(X, Y, c0, F)c:=genfit(X, Y, c0, F) X –X – vector of vector of independent values from data set independent values from data set Y - Y - vector ofvector of dependent values from data set dependent values from data set c0 – starting vector of searched parametersc0 – starting vector of searched parameters F – vector function of independent variable and F – vector function of independent variable and

vector c, consists of approximating function and its vector c, consists of approximating function and its derivatives on parametersderivatives on parameters

c - vector of searched parametersc - vector of searched parameters

Page 27: Data in MathCAD
Page 28: Data in MathCAD

regress Approximation by polynomial functionApproximation by polynomial function

Syntax: Z:= Syntax: Z:= rregress(X, Y, s) egress(X, Y, s) X – vector of independent values from data X – vector of independent values from data

setset Y - vector of dependent values from data setY - vector of dependent values from data set s – polynomial degrees – polynomial degree Z – result: vectorZ – result: vector,, s+1 last elements are s+1 last elements are

parameters of polynomialparameters of polynomial (starting from x (starting from x00 parameter)parameter)

Page 29: Data in MathCAD
Page 30: Data in MathCAD

Linear, cubic, polynomial - splineinterpolating approximation

Approximation by Approximation by linear (cubic etc.)linear (cubic etc.) spline spline function function Syntax: Z:=lspline(X, Y)Syntax: Z:=lspline(X, Y) (cspline, pspline)(cspline, pspline)

X – vector of independent values from data setX – vector of independent values from data set Y - vector of dependent values from data setY - vector of dependent values from data set Data in set has to be sorted! Manually or by useData in set has to be sorted! Manually or by use

of of function csort: W:=csort(W,i), W – matrix function csort: W:=csort(W,i), W – matrix of data, i – nr of ordering columnof data, i – nr of ordering column

Z – result: vector of parameters of cubic spline Z – result: vector of parameters of cubic spline functionfunction

Page 31: Data in MathCAD

Can be derivate

Can be integrate

Page 32: Data in MathCAD

Interpreting function Operates on vectors obtained from regress and spline Operates on vectors obtained from regress and spline

family functionsfamily functions Building the continuous approximating function on Building the continuous approximating function on

the base of determined parametersthe base of determined parameters Syntax: F(x):=interp(Z, X, Y, x) Syntax: F(x):=interp(Z, X, Y, x)

Z – vector given by approximating functionZ – vector given by approximating function X – vector of independent values from data setX – vector of independent values from data set Y - vector of dependent values from data setY - vector of dependent values from data set x – independent valuesx – independent values

Interpreting function is implicit but can be derivateInterpreting function is implicit but can be derivatedd and integrateand integratedd

Page 33: Data in MathCAD
Page 34: Data in MathCAD

MathCAD

The animationThe animation

Page 35: Data in MathCAD

Animation

EnhanceEnhancess understanding of numerical understanding of numerical outputoutput

Animations shows time dependences in real Animations shows time dependences in real time, fastened or slowed down.time, fastened or slowed down.

Make impression on viewersMake impression on viewers

Page 36: Data in MathCAD

Animation

Base of animation is variable called:Base of animation is variable called:

FRAMEFRAME Built inBuilt in, , integer typeinteger type Definition only in dialog box of animationDefinition only in dialog box of animation Parameters are: Parameters are:

starting valuestarting valueending valueending valueframe rate (frames per seconds)frame rate (frames per seconds)

Page 37: Data in MathCAD

Creating animation Solve a problem Solve a problem (e.g. (e.g. create functioncreate function)) Assign counting variable to FRAMEAssign counting variable to FRAME Define a variable representing each state of Define a variable representing each state of

solution assigned to counting variablesolution assigned to counting variable Create plot to animateCreate plot to animate DDisplay animate dialog box and isplay animate dialog box and sselect plot elect plot Define FRAME variable parametersDefine FRAME variable parameters Choose format of compression for animation Choose format of compression for animation

recording.recording. Press Animate button. Press Animate button.