CE 502 SWI, Assignment # 3

        Due by 5:00 p.m. on Monday, February 28, 2000


Reading Assignments:

  1. Finish reading the sections of the 303 WWW Notes on:
  2. In the Matlab Section of the Notes, finish reading all topics in:
  3. Start reading about Matlab functions in Chapter 10.


Add these Unix commands to your vocabulary: Table 3.

Laboratory Problems

These problems may be completed with help from any user on Owlnet. You may not copy anyone else's work, but you can get other users to give you suggestions and point out mistakes that should be corrected.

Problems should be completed using the tools suggested and the results stored in a file that the instructor can look at.
One way to do that is to copy the commands you execute and the results you see into a text editor (nedit, xedit, emacs)
and save the file as hw3, then e-mail it to the instructor.

1) The following data gives the production of benzene in several plants for the years 1991 through 1994.

Benzene Production in Tons/day

Plant/ year 1991 1992 1993 1994 1995 1996
Baytown 20.5
22.5
25.5
21.5
19.0
18.5
Baton Rouge 12.3
11.5
10.0
12.5
13.5
13.5
Bayonne 100.3
125.0
120.0
135.0
124.0
135.6

Prepare a bar graph (and of course use help bar in Matlab) of this data. Include appropriate labels written on the chart. This should include the Year as the x label, Tons/Day as the y label and Benzene Production as the title. Use the legend command to show which bar goes with each plant. Next see an example of making a pie chart and use help pie to find out how to show this data on a set of pie charts. Prepare a pie chart giving the amount produced over the six year span by each plant. Add appropriate labels to these graphs.

2) Use the example program yxplot to make a plot of:

  • x going from 0 to 5 in steps of 0.5 and y given by: cos(x)exp(-0.1x). Use the title: Decaying cosine. Label the x axis: time. Label the y axis: Distance from Origin .
  • Try it with TEMPERATURE for the independent variable and PRESSURE for the dependent variable. Make the title read TANK PRESSURE. Input the data in the following table:
  •  TEMPERATURE DEG C   5    10    15    25     50    75  100   150
     PRESSURE ATM (ABS) 2.5  2.75  1.8   1.5    1.2   1.0  0.9  0.073
3) Modify the yxplot program so that you can plot more than one curve with a single execution of the program. First try this in a Matlab session without writing a program. Then the next step should be to develop a program that could plot one, two or three different curves. Each curve would be specified by two vectors of data giving the independent and the dependent variables. Thus the set of points on the X-axis might vary from one curve to the next.

In your final version of a program, the number of curves to be input should be arbitrary. Let the program determine how many plots are to be done. Read the manual to see how to arrange the data. Use this modified version to plot the vapor pressure of water and ethanol vs temperature.

The vapor pressure data to be plotted is given in this text file.

Make sure that your labels on the axes reflect the meaning of this data and the title describes the curves produced. In this case the temperatures are given in oC and the pressures are in atmospheres. Use the legend command to show which curve is for water and which one is for ethanol. Your program should allow the user to annotate the plot completely.
 

Test Problems

You may work these problems with help ONLY from the course instructor.
 

1) This problem will look at fitting a curve through the experimental vapor pressure data introduced in Lab Problem 3. The MATLAB functions: polyval and polyfit do this job in MATLAB. Fit both a straight line and a quadratic though the water data. Plot both the original data and the data that would be given by the polynomial fit. Then try the same thing but with the natural log of the vapor pressures instead of the vapor pressures. Which fit looks most promising? For the approximation that appears best, repeat with the ethanol data. The hold command may be quite useful in this problem. Use help on it and go to the notes to see an example.

2) Now we would like to improve on the plot produced in the previous Matlab problems. This requires that you find out more about the plotting functions. Read about them in the User's Guide or see what you can find with on-line help.

Our object in this problem is to plot the experimental data as points (without connecting them by a line) on the same graph as the line given by your approximation. We will do so for just the water data for a polynomial approximation of degree 2 (a quadratic approximation).

Use the text or gtext function to write a message saying the line was generated by the quadratic equation given by the vector found by polyfit.