experiment - napa valley college 120... · 2014-10-11 · experiment graphing in excel introduction...
TRANSCRIPT
EXPERIMENT GRAPHING IN EXCEL
Introduction
In this lab you will learn how to use Microsoft Excel to plot and analyze data that you obtain
while doing experiments. In this lab you learn how to
Enter data into a spreadsheet
Have the spreadsheet do calculations for you
Create a graph
Properly format the graph with your name, date, title and properly labeled axes
Find the slope and intercept of the plot
How to Enter Data into a Spreadsheet
Entering your data into a spreadsheet is always a three step process. These steps are:
1. Click on the cell where you want the data to go.
2. Type your data into the cell.
3. Press the ENTER key on the keyboard or click on another cell with the mouse.
Start anywhere and type the following data into the spreadsheet
Speeding up data entry
Many people use the mouse when moving around their spreadsheet. Using the mouse, though, is
the slow way of doing anything on a computer. It's fine if you have only a small amount of data
to enter or if you're not in a hurry.
To speed up your data entry use the keyboard. Below is a list of keys that you can use when you
want to quickly enter your data.
Enter key: enters the data and moves the active cell highlight down to the next cell in the
current column.
Tab key: enters the data and moves the active cell highlight to the next cell in the current
row.
Arrow keys: enters the data and moves the active cell highlight to the next cell in the
direction of the specific arrow key pressed. For example, if the up arrow is pressed, the
active cell highlight moves up to the next cell in the current column.
Esc key: cancels the current data entry.
To Create a Graph
Select the data by dragging your mouse across all the data cells.
Now, click on Insert, Scatter…, and click on Scatter.
The following graph will automatically appear in the middle of your spreadsheet.
We want to find the slope and intercept of this graph. There are two ways of doing this.
Good way –
Right mouse click on any of the blue data points on your graph. A menu will pull up that asks
you what you want to do. In this case, you want to Add Trendline…
Once selected, a new menu will allow you to format
the Trendline you want to use. In most cases, you
will want to choose the linear option and you will
want to show the equation (with the slope and the
intercept) on the graph and the R-square value. The slope and intercept are pretty self-
explanatory but the R-square term measures how well your data fits the line. The closer R-
square is to 1.0 the better the fit. After making these selections you can close this dialogue box
and take a look at your graph. You should see the following.
The slope and intercept is shown on the graph and the R2 term tells us that our data is very
linear.
The BEST Way –
Keep in mind that there should be no writing within the graph. That is, the slope, intercept, and
R2 should NOT be seen anywhere on the graph. Even so, you need this information so most
students will follow the steps given above, write down the information and then delete it from
the graph. Okay, so you can do that, but there is a better way that preserves this information but
doesn’t show it on the graph.
Entering Equations into Excel
Excel is a very smart program. It has a number of built in functions that you can use to do math
and statistical analysis. We are going to use Excel’s built-in functions to have it calculate the
slope and intercept of our graph.
Begin by finding an empty cell and type in “=slope.” Any time you start by typing an equal sign
(=) into a cell it tells Excel that you want to do some math. In this case, we want to determine the
slope from our data. Excel will automatically help you by telling you what it needs to
accomplish the task. In this case, Excel needs to
know the range of your y values and the range of
your x values with a comma between them. You
will begin by telling Excel where your y values
are in your spreadsheet (see picture). Once you
have done that, type in a comma and select your x
values and close parentheses. Pressing the Enter
key completes the process.
You can calculate the intercept in the same way. In a cell below the slope, type in “=intercept(“
and then type in the range for the y and x values and press enter.
You now have the slope and intercept of your plot. You will notice that there are more digits in
this calculated intercept than the one on your graph. This is one advantage of having Excel
calculate it for you. You can increase the number of digits given in the answer by telling Excel
how many digits that you want to see. To change the number of digits do the following.
Highlight the slope and the intercept by clicking and dragging your mouse across them. After
they have been selected, right mouse click this selection.
Select “Format Cells…” A new menu will appear that will allow you to change how the
numbers in the cells will appear. If desired, it also will allow you to change the color of the text,
its alignment, put boxes around it and other kinds of formatting. For now, select “Number” and
change the number of decimal places to four (4). Click on “Okay.”
Your numbers will now have four digits past the decimal point.
You will notice that you now have all of the information that is on the graph except the R-square
value. To determine the R2 you will follow the same procedure you used with the slope and
intercept but the command for the R2 in Excel is RSQ(). Try it and see if you can get Excel to
calculate the R2 value for you.
Labeling the Graph
Now that you have made a graph and found its slope, intercept, and R2, it is now time to label it.
To add a title and label the axes you need to access the Chart Tools, Design… menu. To do this
you need to simply click somewhere on the graph (which selects it). This will usually bring up
the Chart Tools, Design menu but if it does not, you will notice that Chart Tools has been
highlighted at the top your screen. By selecting Design, the Design menu will appear.
The menu item you will select is circled in red. Select that chart layout. As soon as you do your
graph will change. A place for a title will appear and so will your axes labels. Unfortunately,
you will also lose your slope, intercept and your trendline. Fortunately, we already know how to
add a trendline. Add the trendline back to your graph but do not tell it to put the equation or R2
term on your graph. Your graph should look like this.
Now, delete the legend ( Series 1 and ‒ Linear (Series1)) by selecting it and hitting the delete
key. Your graph should look like this.
To change the labels, simply click on them, highlight the word and start typing. In this case,
your data is actually the diameter and the circumference of a circle so you need to add this to the
title. Your title should be “Circumference versus Diameter.” Remember, in a title we always
put y versus x, never the other way around. Use the same procedure to change the x and y axes,
except that we must also use Guggenheim notation when expressing units on our axis labels so
our axes must be, Circumference/cm and Diameter/cm. When you are finished your graph
should look like this,
This is looking pretty good except that I think that the axes should not be bolded and use a large
font while the title uses a font that is too large. To change the font attributes you can select the
title and, if it is not already present, click on the Home tab at the top of the screen. This will
cause the font menu to appear in the ribbon. Or, if you like, you can right mouse click the text
and select “Font.” Either way you can change the attributes of your font. In this case I want to
change the axes to 12 point and remove the bold, and I want to make the title 14 point and
remove the bold.
Adding your Name and the Date to the Graph
To add your name and date to the graph you must add a Text Box for each of them. Begin by
clicking anywhere on your graph and then, in the top menu select Insert, Text Box. You insert a
text box by using your mouse to “draw” a box on your graph. Put your name in the box and then
do the same for the date. You will notice that these text boxes may have dark lines around them.
You can remove these lines by right mouse clicking each box and selecting Format Object…
You want to change the Line Color to No line. The box will no longer have a line around it.
Finally, we have one detail left that will make our graph perfect. You will notice that the x axis
has numbers but there are no marks on the graph to indicate the exact position of each number.
These are “tick” marks and must be added to both axes. To add these tick marks you can right
mouse click the axis (just click on one of the numbers) and select Format Axis… You want to
add Major tick marks to the outside of the graph on both axes. Your graph is now finished.
One last detail. When you print the graph it will print the dark line that you see around your
graph. You can remove this line by selecting the graph, right mouse clicking and selecting
Format Chart Area… In this menu you will see Border Color. Select No line. Now, when you
print your graph there will not be a dark line around it.
Congratulations! You’ve made your first graph in Excel. Please make a print out of your graph
and hand it into your instructor.
Using Equations in Excel
Now that you’ve made a graph in Excel there may be other things that you need to do. You may,
for example be asked to do a calculation based on the slope and intercept of your graph.
Suppose, for example you were asked to calculate the circumference of a circle whose diameter
was 35 cm. How would you do it using Excel?
Entering Equations
To have Excel do some math, you will have to tell Excel what you want to do. Excel will do
math anytime an entry begins with an equal sign (=). For example, you type the following
mathematical operation into any cell and Excel will do the math for you.
Cell Entry Result
= 3*2 6
= 3^2 9
=ln(10) 2.302585093
=sqrt(10) 3.16227766
=1/398 0.002512563
=average(3,7,12) 7.333333333
Excel is smart and has a lot of built in functions so it knows how to average, find the square root,
and take the natural log of a number.
In this case, you want use Excel to use the slope and intercept that you obtained from your graph
to calculate the circumference of a circle given its diameter. So, you want to solve the following
equation,
Circumference = m × diameter + intercept
You will notice that, in our example, the slope is found in cell E4 and that the intercept is right
below it in cell E5. You can tell Excel to use the slope and intercept in your equation by
referencing these cells. In addition, you can put the diameter you want to use in another cell (E8)
and then reference all of these when writing your equation. So, your equation is,
= m × diameter + intercept
But it will look like,
= E4 * E8 + E5 (it is not necessary to use capital letters)
When you press ENTER the result of your calculation appears.
Press Enter
Writing your equations using cell references is the best way to do it. That way, you can change
any one of the variables and instantly see the result without having to retype the formula. For
example, if you want to know the circumference of a circle with diameter 87.3, just replace the
current diameter value (35) with the new number. Your new circumference will appear instantly.
Column and Row Facts Columns run vertically in a spreadsheet and are identified by a letter.
Rows run horizontally and are identified by a number.
There are 1,048,576 rows, 16,384 (A to XFD) columns, and 17,179,869,184 cells in a
worksheet.
Filling and Copying Cells
Changing the diameter allowed you to instantly see a new circumference in the equation above,
but sometimes you will want to do a calculation many times and see the all of the results.
Suppose you want to see the area of all the circles with diameters between 0 and 100 cm in steps
of 5 cm. How would you do it? You can begin by entering all the numbers between 0 and 100
in steps of 5 but doing this by hand is difficult, so do this.
Choose any cell (with lots of room below it) and type in zero (0). Using your mouse, starting
with the zero, drag down the column until at least 20 cells have been selected. Now, in the upper
right had corner there is a Menu selection called Fill. Select it and then select Series.
The following menu will appear.
You want a linear progression of data in steps of 5 up to a maximum value of 100. So the step
value is 5 and the stop value is 100. Fill these in and press okay. These values will appear in
your spreadsheet.
Now, the equation for the area of a circle is Area = πr2. The values you just put in are the
diameter so you will need to divide these numbers by two. In addition you will have to square
this number and multiply by pi. We do not approximate pi for these calculations. Excel knows
the value of pi. Find any empty cell and type in “= pi( )” and press enter. The value of pi will
appear in this cell.
Now that you have done this you are ready to enter
the equation that will calculate the area of a circle.
You should already have pi available on your
spreadsheet so you must divide each diameter by
two, square it, and multiply by pi. So the formula is,
Area = pi*(diameter/2)^2
But we will use cell references for everything. For
this example, the formula will be,
=G2*(G4/2)^2
If we copy and paste this formula into all of the cells
below it, all of the cell references will increment by
one for each additional position below the original
cell. Therefore, pasting this formula into the cell
below it gives,
=G3*(G5/2)^2
This is okay because G5 contains the next diameter
but pi is in cell G2, not G3. So, to keep Excel from
incrementing the position for pi we use dollar signs
to indicate things that should not change when we
copy and paste. In this case, pi would no longer be in
G2 but in $G$2 (don’t increment G and don’t
increment 2). Making this change to the formula and
copying it, achieves our goal.
=$G$2*(G4/2)^2
Now, make a plot of the area vs. radius, add a trendline and label the graph. Turn it in with your
lab. What is the slope of this plot?
Exercise: Plotting Your Personal Data
Using the instructions given above, use Excel to make a plot of circumference vs. diameter for
the beakers you measured in Lab #1. Find the slope and the intercept.
Please turn in the following with lab #1 due on Thursday.
1. A hand made plot of circumference vs. diameter using your lab data.
2. An Excel plot of circumference vs. diameter using your lab data.
3. A plot of circumference vs. diameter from today’s work in Excel
4. A plot of the area vs. radius from today’s work in Excel