# Maple commands for reading in data points and plotting them. # # The data is created by your C program which sends its output to a # file. This file, called `temp.data` here, should contain data in 2 # columns, separated by spaces. The very first row of the file # temp.data will contain the numbers N and T in that order. The # subsequent rows should contain the index i in the first column and the # temperature u[i] in the second column. # # We start by clearing the working memory and loading the plots package. > restart; with(plots): # The numbers in the file temp.data will be interpreted by Maple as # floating point numbers # and stored in a list called data: > data := readdata(`temp.data`, [float,float]): # If N and T are small, you might want to print your list data before # you go on. You can do this by changing the colon at the end of the # command above to a semicolon. # # Next we pull out the values of N and T from the first entry data[1] # of the list data. We want these numbers to be integers, and they were # read in as floats, so we use trunc to throw away the part after the # decimal point. Finally, we throw away data[1] from data since we have # now saved this information as N and T. # # (Note that in maple op(1..3,data) means take elements 1 through 3 of # the list data. The expression nops(data) means the total number of # elements in the list data. So op(2..nops(data), data) means take the # elements data[2], data[3], ...up to the last element of data.) # > N := trunc(data[1][1]); T := trunc(data[1][2]); > data := [op(2..nops(data), data)]: # Now for time from i=1 to i=T, that is for each time step, we make a # list of the temperatures. This is stored as temps[i]. Here we just # peel off the appropriate sublist from the list data, save it as # temp[i], and delete it from the list data. > for i from 1 to T do > temps[i] := [op(1..N+1, data)]: > data := [op((N+2)..nops(data), data )]: > od: # Now we make a list of plots p[i] = plot of position i versus # temperature u[i] at the ith time step: > for i from 1 to T do > p[i] := plot(temps[i], style = line): > od: # Finally, we display all the plots together. This makes a multiframe # plot that we can play like a movie, or at least a documentary...When # the plot appears, click on it and new controls will appear at the top # of the screen. If you click on Help (upper right corner of your Maple # window) and select Balloon Help you can get explanations for these # control. Select Balloon Help again to turn off the balloons and # actually run the movie. > i := 'i': display([p[i] $ i = 1..T], insequence = true);