Modifications

First, you should take the program that you wrote to solve the previous lesson's homework assignment and modify it by completely removing the body of the function print_rod. You should also add a parameter to the function's interface, so that you end up with

void print_rod(float rod[], int rod_points, FILE* file) {
}

You will use the extra argument, ``file'', as the first argument to the calls to fprintf that you'll be putting into print_rod.

Next, you should write a new body for print_rod so that it will print out the Maple command that is required to produce a plot of the rod's temperature for a single instant in time. There are four such plot commands in the example output. Each such command begins with ``plot(['' and ends with ``])''. Be sure that all of your output goes to ``file''.

Finally, you will need to modify the main procedure. It will need to open an output file, and print to the file the parts of the command that appear before, between, and after the various plotting commands. You should pass a pointer to the file that you opened as the third argument to print_rod.


Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah