Download as pdf or txt
Download as pdf or txt
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
1

1 .. 7

Data for a Sessions Pump Discharge, Q (L/s) Power, P (kW) 3.00 28.5
7.00 10.00 33.8 39.1

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. 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.

13.50 17.00 20.00 25.00

43.2 48.0 51.8 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 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. b

60 55

PREG n P n

50 45 40 35 30 25 0 5 10 15 20 25

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

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