Download presentation
Presentation is loading. Please wait.
1
An Introduction to MathCAD
Animation, Interpolation and other pretty pictures 1 1
2
Animation Example Example from our LCR circuit
3
Animation #2 Basics 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
4
Animation #3 Hints “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
5
Animation #4 More 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:
6
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
7
Vector Field Plots #2
8
Data Analysis #1 Get 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
9
Data Analysis #2 Select 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
10
Data Analysis #3 Smoothing Data
medsmooth(vy,n) returns vy smoothed with running medians
11
Data Analysis #4 Linear regression
Slope & intercept functions take vectors of X & Y values
12
Data Analysis #5 Interpolation
2 stage process Fit polynomial through points cspline – cubic spline Bspline – B-spline Interpolate using polynomial obtained in stage 1 interp
13
Cubic Spline fit & Interpolated Fit
14
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
15
Function Fitting Example #1
Determine parameters a & b
16
Function Fitting Example #2
Rewrite f(x) and derivatives Replace a,b by u0, u1… Find partial derivatives of f(x) Create vector of function & pds
17
Function fitting Example #3
Create vector of guess values Call genfit to solve Define function using params
18
Function Fitting Example #4
Plot f(x) against data
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.