Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Data processing in MathCAD. Data in tables Tables are analogous to matrices Tables are analogous to matrices The numbers of columns and rows can be dynamically."— Presentation transcript:

1 Data processing in MathCAD

2 Data in tables Tables are analogous to matrices Tables are analogous to matrices The numbers of columns and rows can be dynamically changed (in contrast to matrix) The numbers of columns and rows can be dynamically changed (in contrast to matrix) To enter table: To enter table:  Menu: Insert/Data/Table (MC v. 15)  In placeholder type variable name which will be assigned to table  In cells type the values  Each rows and columns must contains the same number of data. If data are missing the value ‘0’ will be assigned Access to data in table is similar to the one in matrix case. Access to data in table is similar to the one in matrix case.

3 Data in tables

4 Row/column appears in table when only 1 data is inserted into the cell: Row/column appears in table when only 1 data is inserted into the cell:  table size = specified cell in the lowest row and in last column  Unfilled cells contains 0  Once specified cell can not be removed!  To overcome problem: create new matrix with correct number of rows i and columns j using

5 External data sources: Data in files The most popular file formats accepted by MathCAD: The most popular file formats accepted by MathCAD:  Text files  Excel worksheets To insert text file containing data: To insert text file containing data:  Menu: Insert/Data/File Input  Chose file format  Browse to the file location  path could be relative or absolute  In the placeholder type variable name that will be assigned to the contents of file

6 Inserting the text file

7 Changes in the text file location Changes in the text file location

8 Inserting the Excel worksheets A range of Excel cells can be inserted into the MathCAD A range of Excel cells can be inserted into the MathCAD There can be more then one range in single insertion There can be more then one range in single insertion One variable is being assigned to one range One variable is being assigned to one range All variables forms a vector All variables forms a vector Cells can contain numbers as well as text (in contrast to table and text files, ver. 2001) Cells can contain numbers as well as text (in contrast to table and text files, ver. 2001) Worksheets can be edited (double-click) using all Excel functions (object embedded -Excel has to be installed in system). Worksheets can be edited (double-click) using all Excel functions (object embedded -Excel has to be installed in system).

9 Inserting the Excel sheets To insert worksheet: To insert worksheet:  Menu: Insert/Component/Excel  Browse file or create new  Choose number of ranges for input and output (relatively to Excel worksheet). If no data have to be inserted into the Excel worksheet fill inputs number by 0  Type ranges corresponding to outputs – e.g. A1:B10 (if worksheet name is different from Sheet1 type sheet name – e.g. Sheet4!A1:B10)  In placeholder(s) type variable(s)  Number of outputs/inputs and range of cells can be edited in properties of insertion

10

11 MathCAD files as data source in MathCAD Main MathCAD document can use data included in other MathCAD documents Main MathCAD document can use data included in other MathCAD documents Access to data is possible after embedding MathCAD file: Access to data is possible after embedding MathCAD file:  menu: Insert/References,  Brows the file  Below the insertion point all data, definitions from inserted file are valid in the main document but worksheet options from main document overwrite options in inserted document  Problem: matrix/vector elements numbers when array origin is different in main and inserted doc.

12

13 Data analysis and optimisation Approximation

14 definition Approximation is a part of numerical analysis. It is concerned with how functions f(x) can be best approximated (fitted) with another functions F(x) Approximation is a part of numerical analysis. It is concerned with how functions f(x) can be best approximated (fitted) with another functions F(x)

15 application Simplifying calculations when original function f(x) is defined by complicated expression Simplifying calculations when original function f(x) is defined by complicated expression design of continuous dependency when function f(x) is described on discrete set of arguments. If the form of approximating function is given only values of function parameters showing the best approximation have to be determine. design of continuous dependency when function f(x) is described on discrete set of arguments. If the form of approximating function is given only values of function parameters showing the best approximation have to be determine.

16 types of approximation Interpolating approximation Interpolating approximation Uniform approximation Uniform approximation Square-mean approximation Square-mean approximation

17 Interpolating approximation Needs to satisfy condition: function given f(x) and approximating function F(x) have the same values on the set of nodes and (sometimes) the same values of derivatives (if given) too. Needs to satisfy condition: function given f(x) and approximating function F(x) have the same values on the set of nodes and (sometimes) the same values of derivatives (if given) too.

18 Uniform approximation Function F(x) approximating function f(x) in the range [a,b], satisfying condition: maximal residuum is set to minimum Function F(x) approximating function f(x) in the range [a,b], satisfying condition: maximal residuum is set to minimum

19 Square-mean approximation Approximating function is determined by the use of condition: Approximating function is determined by the use of condition: Geometrically condition means: The area between curves representing functions have to reach minimum.

20 Condition for discreet set of arguments: Condition for discreet set of arguments: Square-mean approximation

21 Function: Function: minimize(function, p1, p2,...) can be used to determine parameters of approximating function minimizing the sum of square deviations between values given in the table and calculated from the function. can be used to determine parameters of approximating function minimizing the sum of square deviations between values given in the table and calculated from the function.  function calculates the sum of square deviations as a function of parameters.  p1, p2 – parameters of approximating function Square-mean approximation in MathCAD

22 Approximating algorithm: Approximating algorithm: 1. Insert data to be approximated 2. Build the approximating function 3. Create a counting variable with values from 0 to number of data minus 1 4. Build function E that calculates sum of square of deviations with parameters of approximating function as variables 5. Assign starting values of parameters 6. Use the function minimize to minimize the E function (deviations). Square-mean approximation in MathCAD

23

24 Advantageous of minimize function: Advantageous of minimize function:  simple  explicit  suitable for any approximating function  can be used in optimisation problem solving

25 Other MathCAD tools for approximation

26 genfit Syntax: c:=genfit(X, Y, c0, F) Syntax: c:=genfit(X, Y, c0, F)  X – vector of independent values from data set  Y - vector of dependent values from data set  c0 – starting vector of searched parameters  F – vector function of independent variable and vector c, consists of approximating function and its derivatives on parameters  c - vector of searched parameters

27

28 regress Approximation by polynomial function Approximation by polynomial function  Syntax: Z:= regress(X, Y, s)  X – vector of independent values from data set  Y - vector of dependent values from data set  s – polynomial degree  Z – result: vector, s+1 last elements are parameters of polynomial (starting from x 0 parameter)

29

30 Linear, cubic, polynomial - spline interpolating approximation Approximation by linear (cubic etc.) spline function Approximation by linear (cubic etc.) spline function  Syntax: Z:=lspline(X, Y) (cspline, pspline)  X – vector of independent values from data set  Y - vector of dependent values from data set  Data in set has to be sorted! Manually or by use of function csort: W:=csort(W,i), W – matrix of data, i – nr of ordering column  Z – result: vector of parameters of cubic spline function

31 Can be derivate Can be integrate

32 Interpreting function Operates on vectors obtained from regress and spline family functions Operates on vectors obtained from regress and spline family functions Building the continuous approximating function on the base of determined parameters Building the continuous approximating function on the 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 function  X – vector of independent values from data set  Y - vector of dependent values from data set  x – independent variable (local) Interpreting function is implicit but can be derivated and integrated Interpreting function is implicit but can be derivated and integrated

33

34 MathCAD The animation

35 Animation Enhances understanding of numerical output Enhances understanding of numerical output Animations shows time dependences in real time, as well as speeded up or slowed down. Animations shows time dependences in real time, as well as speeded up or slowed down. Make impression on viewers Make impression on viewers

36 Animation Base of animation is variable called: Base of animation is variable called:FRAME  Built in, integer type  Definition only in dialog box of animation  Parameters are:  starting value  ending value  frame rate (frames per seconds)

37 Creating animation Solve a problem (e.g. create function) Solve a problem (e.g. create function) Assign counting variable to FRAME Assign counting variable to FRAME Define a variable representing each state of solution assigned to counting variable Define a variable representing each state of solution assigned to counting variable Create plot to animate Create plot to animate Select plot area Select plot area Display animate dialog box and select plot Display animate dialog box and select plot Define FRAME variable parameters Define FRAME variable parameters Choose format of compression for animation recording. Choose format of compression for animation recording. Press Animate button. Press Animate button.


Download ppt "Data processing in MathCAD. Data in tables Tables are analogous to matrices Tables are analogous to matrices The numbers of columns and rows can be dynamically."

Similar presentations


Ads by Google