Transcript LectureX
PH15010
Laboratory Techniques An Introduction to MATHCAD
Simple X-Y plots
• ‘Quickplot’
• Plot functions with 1 parameter
• Use with built-in & user defined
• Insert|Graph|X-Y plot
Simple X-Y Plot #1
Y-axis placeholder
X-axis placeholder
Sizing grab-handle
Simple X-Y Plot #2
Plot of sin(x) vs x
1
0.5
sin ( x)
0
0.5
1
10
5
0
x
5
10
Plot Formatting
• Double click in graph
• Format|Graph|X-Y Plot…
• Dialog box
– Gridlines, Numbered Axes, Log
Scales
– Traces: Colour, Points, Lines &c
– Axis titles, legend
– Defaults
Doing More with Plots
#1
• Add more curves to y-axis
• Fix scale on x- & y-axis
• Add markers on x- & y-axis
- from dialog box
Scaling plot axes
y-axis scale
placeholders
22.754
30
20
10
sin ( x)
cos ( x)
0
tan ( x)
10
20
22.754 30
10
10
x-axis scale
placeholders
5
0
x
5
10
10
Doing More with Plots
#2
2
2
1
sin ( x)
cos ( x)
0
tan ( x)
1
2
2
4
4
3
2
1
0
x
1
2
3
4
4
Dealing with
Experimental Data
• 5 stage process
–
–
–
–
–
Get data into MathCAD
Process data (scale, units etc)
Plot Data
Fit curve (line) to data
Compare theory with experiment
Getting Data into
MathCAD
• Put data in matrix
– 1 column per measurement
– 1 row per data point
• Use Input Table
– Insert|Component|Input Table
• Table re-sizes & scrolls as
needed
Data Input Example
• Resistor Experiment
• Apply voltage, measure Current
Voltage Current (mA)
Readings
0
0
1
2
3
4
5
6
1
0
1
2
3
4
0
1.23
2.45
3.7
4.92
1 row per
reading pair
Process Experimental
Data #1
• Extract columns with column
operator M<>
– Insert into worksheet from
• Matrix toolbar
• <ctrl>-6
– Fill in column number to extract
– Numbering starts at 0
Process Experimental
Data #2
Readings
0
0
1
2
3
4
1
0
1
2
3
4
0
VApplied Readings V
1
IMeas ured Readings mA
0
1.23
2.45
3.7
4.92
Input table as
before
Extract Voltage
to vector & apply
units
Same for current
Check on extracted
vectors
• Single column
• Converted to base units
• Scroll bars if needed
0
1
VApplied 2 V
0
1.23 10
3
IMeas ured 2.45 10
3
3
3.7 10
4
4.92 10
3
3
A
Plotting data
• X-Y Plot can plot 1 vector
against another, if both vectors
have same number of elements
• Use plot formatting to change to
single points
Plotting data Example
3
4.92 10
0.006
0.004
IMeasured
0.002
0
0
0
0
1
2
VApplied
3
4
4
Fit curve/line to data
• Only simple straight line fits for
now
– slope(Vx,Vy)
– intercept(Vx,Vy)
• Details in help system
• Units carry through calculation
• Sometimes need 1/slope
Slope calculation
-Resistor Example
RMeas ured
1
s lope( VApplied IMeas ured)
RMeas ured 812.348
Compare theory to
experiment
• Create function
• Plot on same graph as
experimental data
• Use multiple variables on x- and
y- axes
• Separate items on axes with
commas
Compare theory to
experiment
ITheory( vv)
• Function gives
theoretical
current
vv
RMeas ured
ITheory( 1 V) 1.231 mA
ITheory( 2 V) 2.462 10
3
A
• Test function at
a couple of
points
Plot theory & data
3
6.15510
Multiple
items on x& y-axes
0.006
IMeasured
ITheory ( vv )
‘vv’ exists
only to make
the plot
0.008
0.004
0.002
0
0
0
0
Scale x-axis to suit
1
2
3
VApplied vv
4
5
5