an introduction to mathcad animation, interpolation and other pretty pictures
TRANSCRIPT
![Page 1: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/1.jpg)
An Introduction to MathCAD
Animation, Interpolation and other pretty pictures
![Page 2: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/2.jpg)
2MathCAD #7 dpl 2001
AnimationExample
Example from our LCR circuit
![Page 3: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/3.jpg)
3MathCAD #7 dpl 2001
Animation #2Basics
Use FRAME variable FRAME automatically set by
mathCAD for each frame of animation
Select View|Animation… to bring up animation dialog
Give start & end values for FRAME
Select area to animate Select Animate to produce Save As… to create .avi file
![Page 4: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/4.jpg)
4MathCAD #7 dpl 2001
Animation #3Hints
“Error initialising Video Stream” => Nothing Selected
May want to scale FRAME Animations can:
– Take a long time to create– Produce big files
Windows video player allows thumb bar to step forward & back
![Page 5: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/5.jpg)
5MathCAD #7 dpl 2001
Animation #4More Hints
Fix scale on graphs Don’t need to include
calculations in animation Echo FRAME= in shot If scaling, echo scaled variable For frequency plots, scale
FRAME thus:PtsPerDecade 5
10
FRAME
PtsPerDecade
![Page 6: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/6.jpg)
6MathCAD #7 dpl 2001
Vector Field Plots #1
Plot matrix of complex numbers Each point shown as vector Plot scaled so that largest vector
is gap between points Useful for:
– Electric fields– Magnetic fields– Dynamic Flows– Plotting Gradient of functions
![Page 7: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/7.jpg)
7MathCAD #7 dpl 2001
Vector Field Plots #2x 0 19 y 0 19
Mx y y ei x 0.3
M
![Page 8: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/8.jpg)
8MathCAD #7 dpl 2001
Data Analysis #1Get data from file
Read data in from datafile Use either:
– Insert|Component|File Read or Write & follow the wizard
– READPRN(“filename”) Reads data from file into vector
or matrix File Read component offers
many more file types
![Page 9: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/9.jpg)
9MathCAD #7 dpl 2001
Data Analysis #2Select the data we want
Use matrix functions to select data we are interested in
Rows(M) & Cols(M) to get size of data array
Submatrix(M,rs,rf,cs,cf) to select rectangular chunk
M<x> to select column Csort to sort array Augment & stack to build
arrays
![Page 10: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/10.jpg)
10MathCAD #7 dpl 2001
Data Analysis #3Smoothing Data
medsmooth(vy,n) returns vy smoothed with running medians
smootheds
s 50 medsmooth data s( )
600 610 620 630 640 6500
200
400
600
800
smootheds
i
i
![Page 11: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/11.jpg)
11MathCAD #7 dpl 2001
Data Analysis #4Linear regression
Slope & intercept functions take vectors of X & Y values
0 20 40 60 80 1000
200
400
600
800
Y
X
intercept X Y( ) 4.914
slope X Y( ) 6.955
![Page 12: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/12.jpg)
12MathCAD #7 dpl 2001
Data Analysis #5Interpolation
2 stage process– Fit polynomial through points
cspline – cubic spline Bspline – B-spline
– Interpolate using polynomial obtained in stage 1
interp
![Page 13: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/13.jpg)
13MathCAD #7 dpl 2001
Cubic Spline fit & Interpolated Fit
X-Y data Cubic spline interpolation
90.693003
0.462302
Y
fit z( )
max X( ) 1min X( ) 1 X z
![Page 14: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/14.jpg)
14MathCAD #7 dpl 2001
Function Fitting
Cspline & Bspline fit smooth curve through data points
In physical modelling, we know the shape of the function to fit, just need parameters
Example:– Response of photon counting
detector
![Page 15: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/15.jpg)
15MathCAD #7 dpl 2001
Function FittingExample #1
Determine parameters &
1 107
1 106
1 105
1 104
1 103
0.01 0.1 10.1
1
10
100
1 103
1 104
1 105
Data1
Data0
Fit to function f x( ) x e x
![Page 16: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/16.jpg)
16MathCAD #7 dpl 2001
Function FittingExample #2
Rewrite f(x) and derivatives Replace a,b by u0, u1… Find partial derivatives of f(x) Create vector of function & pds
f x( ) x e x
x e xd
dx exp x( )
F x u( )
u0
x eu1
x
x exp u1
x
u0
x2 exp u1
x
x e xd
d x2 exp x( )
![Page 17: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/17.jpg)
17MathCAD #7 dpl 2001
Function fittingExample #3
Create vector of guess values
guess5 105
7
Call genfit to solve Define function using params
params genfit Data 0 Data 1 guess F
f x( ) F x params( )0
![Page 18: An Introduction to MathCAD Animation, Interpolation and other pretty pictures](https://reader036.vdocuments.net/reader036/viewer/2022082318/56649d095503460f949daedd/html5/thumbnails/18.jpg)
18MathCAD #7 dpl 2001
Function FittingExample #4
Plot f(x) against data
1 107
1 106
1 105
1 104
1 103
0.01 0.1 10.01
0.1
1
10
100
1 103
1 104
1 105
2.451 104
0.066
Data1
f Data0
0.351.542 10
7 Data0