You are on page 1of 2

EGR 120

Introduction to Engineering
File: LINREG.MCD

MathCAD Example: Linear Regression


Problem 3.4 - Graph P vs Q on a linear graph and determine an equation
of the form P = mQ + b (i.e., y = mx + b).
Note: The raw data can be placed into a vector or a matrix.
ORIGIN

Note: ORIGIN (in all caps!) is used here to


define the first element in each
array as element 1 (not zero). If this
statement is omitted, each element begins
at zero.

1 .. 7

Data for a Sessions Pump


Discharge, Q (L/s)
Power, P
(kW)
3.00
28.5

7.00

33.8

10.00

39.1

13.50

Note: To place the data in a matrix:


Select MATH (menu) - MATRICES
and then enter the number of rows
and columns (7 rows and 1 column
in this case). An empty matrix will
appear. Move the cursor within the
array and fill in the desired values.

43.2

17.00

48.0

20.00

51.8

25.00

60.0

Note: Use the built-in functions available in MATHCAD to find the slope and
intercept of the line that best represents the data. If the absolute
value of the correlation coefficient, r, is above perhaps 0.96
then the data is well represented by a straight line.
m slope ( Q , P )
b intercept ( Q , P )
r corr ( Q , P )

m = 1.41
b = 24.249
r = 0.999

so P = (1.41)Q + 24.249

Note: Now define a straight line equation (y = mx + b) using the values


above to draw the straight line that best represents the data.
PREGn

m .Q n

Note: Use the Xi button on the toolbar or a left bracket , [ ,


to create a subscript.
Problem 3.4 - P vs. Q
Note: Two variable are listed

60
55

PREG
n

50

P
n

40

45

35
30
25
0

10

15

20

25

Q
n
(See next page for a larger version of this graph)

on the y-axis, so two


plots are drawn. Only
points (no line) were
plotted for the original
data and only a line (no
points) were plotted for
the regression data.
Double click on the graph
to change graph properties.

Problem 3.4
Power versus Discharge
Sessions Pump

Power, P,
in kW

PREG
n
P
n

Q
n

Discharge, Q, in L/s

You might also like