Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit

Saint Louis University

Computer Science 145
Scientific Programming

Michael Goldwasser

Spring 2009

Dept. of Math & Computer Science

Assignment 03

Plotting Data

Contents:


Overview

Topic: Plotting Data
Related Reading: Ch. 11 as well as coverage from lecture.
Due: Wednesday, 4 February 2009, 11:59pm

Please make sure you adhere to the policies on academic integrity.

For each of the following problems, your goal is to create a script that precisely replicates the figure that we demonstrate. Please make sure to pay attention to issues like axis bounds, labels, titles, legends, and other such aesthetics. You should be submitting four separate fies: arch.m, sunflower.m, population.m, and stock.m. Submit those m-files in accordance with cs.slu.edu/~goldwasser/145/submit.


Problems to be Submitted (20 points)

Problem A)
(5 points)
The Gateway Arch is shaped according to the equation:

\begin{displaymath}y = 757.7 - 127.7 \cosh\left(\frac{x}{127.7}\right) ft.\end{displaymath}

for x ranging from -330 to 330 and cosh the hyperbolic cosine function (it is built-in to MATLAB). Create a script arch.m that produces a figure of the arch matching the following style.

Problem B)
(5 points)
Consider the following rendition of the seeds in a sunflower.

We used the following mathematical model to produce this image. We fix a constant $d = 137.51$ and have $n$ ``seeds'' numbered from 1 to 1000. Seed $s_k$ is plotted at a location

\begin{eqnarray*}
x_k & = & r_k \cdot sin(\theta_k)\\
y_k & = & r_k \cdot cos(\theta_k)
\end{eqnarray*}

where $r_k = \sqrt{k}$ and $\theta_k = \frac{\pi \cdot d}{180} k$.

Create a script sunflower.m that produces such a figure (note well that displayed axes are intentionally omitted from the figure).

For your own amusement you might see what kind of patterns you get by slightly modifying the value of $d$, but submit the version with the prescribed value.

Problem C)
(5 points)

Population growth can often be modeled with the following function:

\begin{displaymath}population = \frac{a}{b + e^{ct}}\end{displaymath}

where $a$, $b$, and $c$ are well-chosen constants, and $t$ measures time. For example, a reasonable model for the population of the United States over time uses the values a = 1.313e-18, b = 4.667e-27 and c = -0.03134, with $t$ measured in years.

For this problem, we want you to graph the population estimate when compared to the actual data for the U.S. population for the period from 1650 up to 2000. We are providing a text file with the actual raw data (statistics taken from wikipedia). Our file has a simple format, starting as

1650        50400
1670       111900
1690       210400
1700       250900
You may download the file population.txt to save in your working directory. It can be loaded from within a MATLAB script with a command such as
pop = load('population.txt');
in which case the variable pop will be set to an array with n rows and 2 columns.

Write a script population.m that reproduces the following figure, with the blue dots being the actual data read from the file and the red line being the estimating function (you can plot the blue dots in MATLAB by using a line specification of 'b.').

Problem D)
(5 points)

Many financial web sites will display charts similar to the one shown below showing the price of the Dow Jones Industrial Average as well as the overall market volume for each day of the most recent year (figure courtesy of Yahoo Finance).

Yahoo also shares its raw data, not just for the year but for its full history. For this assignment, we have downloaded the raw data for the Dow Jones going back to 1928. Our goal is to use MATLAB to reproduce a similar view of the most recent year.

We are providing the raw data in a text file (download here), wih one row for each day of market activity. It is arranged in columns that designate

Year Month Day Daily Opening Price Daily High Price Daily Low Price Daily Closing Price Daily Volume
1928 10 01 239.43 242.46 238.24 240.01 3500000
1928 10 02 240.01 241.54 235.42 238.14 3850000
 ...
2009 01 29 8373.06 8373.06 8092.14 8149.01 5067060000
2009 01 30 8149.01 8243.95 7924.88 8000.86 5350580000

Your goal:
You should create a script stocks.m that generates a figure mimicking the one shown above, as best possible (we do not expect you to be able to match all of the aestetics for this one). We will help you out with the following advice.


Extra Credit (2 points)

Problem E)

Extra credit about stock market graph with high/low error bars coming soon. Goal will be to produce a graph somewhat like the one below, based on use of the errorbar command and the daily open/high/low/close values.



(figure courtesy of marketwatch.com)


Michael Goldwasser
CSCI 145, Spring 2009
Last modified: Friday, 30 January 2009
Assignments | Class Photo | Course Home | Lab Hours/Tutoring | MATLAB info | Schedule | Submit