CS 221 Lab 8 Fall 2011: Graphing and Plotting

Out: 26 October 2011
Due: 10 November 2011

Note Well: The purpose of lab exercises is for you to learn how to solve problems using these tools. It is not for you to type something into MATLAB. As you go through the steps of each exercise, think about what you are doing and what the program is doing, and try to predict what you will see. If you don't understand something, ask your instructor -- that's what he's there for.


Part 1: Plotting a Curve with Excel

Use Excel to create a plot of the displacement (versus time) of a spring-mass-damper system.

Do Examples 5.1 and 5.2, on pages 148–158 of your textbook.

Upload your completed spreadsheet (as a .xlsx file) via the submission portal as "Lab 8 Part 1".


Part 2: Plotting with MATLAB

Use MATLAB to create a similar plot of displacement for the SMD system.

Do Example 5.3 on pp. 159–164 of your text. Instead of typing in the first part of the script manually, you can download one of two versions:

  1. The original version, as in the text.
  2. A loop-free version, which takes advantage of MATLAB built-in functions that operate on arrays. Notice especially the use of the ".*" operator, which take two arrays of the same size and multiplies them element by element, on line 18.
(You will need to do the edits described on page 163 yourself.)

When you save the graph, save it as a JPEG-file. (Note: Be sure to keep a copy of the final m-file for your future reference, but you do not have to turn it in.)

Upload the saved graph (as a .jpg file) via the submission portal as "Lab 8 Part 2".