CSc 4630/6630 Programming Assignment #2

Documentation
The first thing in your program should be documentation, such as the following. This should appear at the very top of your program.
  % program(number).m
  %
  % Author: (Your Name)
  % Account: (your account name, or student e-mail)
  % CSc 4630/6630 Program (this program number)
  %
  % Due date: (put the due date here)
  %
  % Description:
  % (Give a brief description of what your program does.)
  %
  % Input:
  % (State what the program inputs are.)
  %
  % Output:
  % (State what the program outputs are.)
  %
  % Usage:
  % (Give an example of how to use your program.)
  % (For example: out = myabs(in); )
  %
Verify that the help command shows this information.

Objectives

  1. Practice designing a program iteratively.
  2. Practice implementing a program design in MATLAB.
  3. Practice testing a program.
  4. To read/write data files.

Temperature Test
A common problem is to bridge the gap between one program and another. That is, we might have one program that generates output, and desire to use that output as the input to another program. However, the two programs are written with different goals in mind, so the output of the first might be incompatible with the input of the second. This assignment is an example of that kind of problem.

The attached file is called "temp_test.txt", which is plain text. It is the output of a program that controls a burner and a pump, and measures temperatures in two containers. This specific output is the result of a test, where both temperature probes were exposed to the same conditions. They should report the same measurements, and a variation might mean that one of them should be replaced.

The pattern is:
time-stamp elapsed-time step-number container1-name measurement1 "F, Target: " set-temperature1 "F," pump-status-text "status" pump-status-number container2-name measurement2 "F, Target: " set-temperature2 "F," burner-status-text "status" burner-status-number "mix" mixing-status

For example:
1:0:51 0:0:51 2 indirect 162.2 F, Target: 154.0 F, Pump off, status 0 direct 165.0 F, Target: 164.0 F, Heat off, status 0 mix 0

However, there are comments in the file that should be ignored. Also, it is possible that the text "C," might appear before "Target:", if the temperatures are measured in Centigrade.

To see how well the temperature probes match, we need to plot the data. The goal of this assignment is to generate a file containing only the two temperature readings (measurement1 and measurement2) from each line. Given the example line above, your program should write:
        162.2, 165.0
to a file as one line. Of course, it should write all other temperature readings to the file, too.

To do this, it will need to parse the information from the file. We need to make a few assumptions and observations to do this.

To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Design your program by specifying its behavior, identifying the variables and operations it needs to solve the problem, and then organizing the variables and operations into an algorithm. For our purposes, include functions as operations. Then code your design in MATLAB using step-wise translation. Finally, test your program thoroughly.


Turn In Your Work

  1. your source code 
  2. the output where you test the correctness of your program (using a script*). Use more if the testing needs it. 

Make sure to use plain text files (.txt, .csv, or .m, as appropriate).


* A script is short for typescript, where everything typed is saved. This keeps a log of all the input and output. MATLAB provides this capability with the diary command. For example, diary out records all inputs and outputs in a file named ``out''. Do NOT call your script file ``programX.m'', or it may overwrite your homework! Make sure to keep a backup of your work. Type help diary at the MATLAB prompt for more information.