You are on page 1of 33

PH36010

Numerical Methods
Advanced Plotting and Animation

Advanced Plotting in
MathCAD

Polar Plots
3D Plots

Surface
Contour
Scatter
Bar

Vector Field Plots

Polar Plots #1
X-Y Plot wrapped around a circle
90
120

1
60

r=cos2()

0.8
0.6

150

30

0.4
0.2
F( )

180

210

330

240

300
270

3.749 10

33

Polar Plots #2
k 0.2

r=e

r e

0 0.1 6
90
120

40

60

30
150

30

20
10

180

210

330

240

300
270

Uses for Polar Plots


Rotating Machines
Stirling engine
Vibration

Arctic & Antarctic systems

3D surface plots
Simple #1

Plot of data stored in array


Indices of array represent x-y
plane
Value of matrix is z value

Define size of matrix & indices


Determine values for x & y
Fill matrix
Plot

3D surface plots
Simple #2
N

xi

0 N

100

0.1i

f( x y)

Mi j

2
x

f xi yj

yj

0 N

0.1 j

Define size &


indices
Define Range
for x & y
2D-Gaussian
Fill matrix

3D surface plots
Simple #3

3D surface plots
Simple #4 Lighting

Contour Plot
- from 3d plot data
Format plot type -> Contour plot

Simple 3D plots
Limitations
X & Y axes scaled in indices
Suited to continuous single
valued functions
More advanced 3D plots
available

3D Scatter plot

Plot of individual points


Supply with 3 vectors of equal
length (X,Y,Z)
Points plotted:
X0,Y0,Z0
X1,Y1,Z1

3D scatter plot
Photon Scatter in 3D

( XX YY ZZ )

3D surface plots
Parametric Plot
Plot complex surfaces
From Resource Centre Guide to 3D
plotting

( X Y Z)

3D parametric plot
2
Example - 100 for H
X- & YAxes
scaled
in m

( X Y Z100 )

Parametric Plots
How to #1

Rubber sheet N x M
Wrap sheet around surface
XXa,b is x-coord of point a,b

YYa,b is y-coord of point a,b


ZZa,b is z-coord of point a,b
(XX,YY,ZZ) will plot surface

Parametric Plots
Example 1 - Gaussian
N

100

xmin

xmax

ymin

ymax

0 N

0 N

XXi j

xmin x i

YYi j

ymin y j

f( x y)
ZZi j

2
x

f XXi j YYi j

xmax

xmin

N
ymax
N

ymin

Ranges
defined as
before
Fill XX & YY
matrices
Fill ZZ matrix

Parametric Plots
Example 1 - Gaussian
Note:

Axes
scaled

( XX YY ZZ)

The SeriesVector()
program
SeriesVector ( Start Finish nSteps)

Finish Start
nSteps

for i 0 nSteps
Resulti Start i
Result

(increment) and i (loop count) are


local to function.
Function builds Result vector
Returned on last line of program

Parametric Plots
Polar 3D #1
nr
r
n

Xi j

100

0 nr

SeriesVector 0 m 10a 0 nr
30

0 n

SeriesVector( n)
ricos j

Yi j

risin j

Create r vector
0-10 radii, 100
teps
Create vector
-180..180 deg,
30 steps
Fill X & Y
vectors

Paramteric Plots
Polar 3D #2
r

100 ( r )

Define 100 function

a
e 0

1
3

a0

Z100i j

3
a 0 100 ri

Fill Z matrix with


100 function
NB Only depends on r

3D parametric plot
2
Example - 100 for H
X- & YAxes
scaled
in m

( X Y Z100 )

Plot of

2
210

for H

X & Y matrices as before


Z now depends on r,q
r

210( r )

r e

2 a 0

cos( )

32 a 0

Z210i j

3
a 0 210 ri j

3D parametric plot
2
Example - 210 for H

( X Y Z210 )

Pretty Pictures
From Resource Centre

Plot multiple Surfaces

Pretty Pictures #3
Planetary Orbit
3 objects

Planet : (xe,ye,ze)
Star : (xs,ys,zs)
Orbit: (xp,yp,zp)

( xe ye ze) ( xs ys zs) ( xp yp zp)

Animation
Principles
Make output depend on FRAME
Tools|Animation|Record
to display dialog

Fill in first & last frames


Drag cursor around area to animate
Select Animate to go
View with AVI player
Save to disk

Help|Quicksheets|Graphing and
Visualization

Animation
Hints and Tips

Fix scale of graphs


Watch out for:

Size of AVI files


Long calculation times

Can test by using


FRAME:=

Delete afterwards

Put indicator in movie

Animation Example #1
Cannon Ball with drag

Animation Example #2
LCR at resonance

Animation Example #3
Heat Flow in Plate

Animation Example #4
Planetary Orbits

3D with lighting &


shadows

You might also like