contour_sequence4, a MATLAB code which reads one XY coordinate file, and a sequence of U(X,Y) datasets, creates contour plots, and saves them as PNG files which can be combined into an animation (by Quicktime Pro, for instance).

The solution files containing the U(X,Y) data should have 'consecutive' names, such as "fred01.txt", "fred02.txt", "fred03.txt" and so on. The user only has to tell the program to process the first file, and it will automatically continue to process files until it reaches the end of the sequence of names.

The input files:

The X and Y input data files store the values of X and Y for points on a regularly spaced grid. The grid does not have to be evenly spaced, but for this program to work, it must be the case that the (X,Y) points form an M by N grid, and that the value of X or of Y is constant along a grid line!

(In other words, a square grid is fine, but a rectangular grid is OK too. A rectangular grid with constant spacing is fine; a rectangular grid with variable spacing is also OK. But a slanted, "wiggly" or curved grid is no good.)

Each U input data file is assumed to store the value of the associated scalar U.

Also, the grid of points in the data file must be listed in a reasonable order, either by rows or by columns.

Internal processing:

The program has to figure out the grid parameters M and N, and convert the vectors of data X, Y, U into doubly indexed arrays that can be handled by the MATLAB contour routine. Once the contour plot is displayed, an image of it is saved as a PNG file.

Once the first file is processed, the routine checks to see if there is a second "consecutive" file, and it so, it is also processed, and so on, until presumably all files in the sequence have been handled.


contour_sequence4 xy_file u_file
where xy_file contains the node coordinates, and u_file is the first file in a numerically related sequence.


The computer code and data files described and made available on this web page are distributed under the MIT license


contour_sequence4 is available in a MATLAB version.

Related Data and Programs:


dist_plot, a MATLAB code which makes contour plots of the distance function, as defined and used in Persson and Strang's distmesh code;

fem2d_heat, a MATLAB code which solves the 2D time dependent heat equation. The output from this program includes an XY file and a series of U files containing the solution (temperature) at each node. This data is suitable for processing by CONTOUR_SEQUENCE4.

levels, a MATLAB code which makes a contour plot, choosing the contour levels using random sampling.

triangulation_order3_contour, a MATLAB code which makes contour plot of scattered data, or of data defined on an order 3 triangulation.

triangulation_order6_contour, a MATLAB code which makes contour plots of data defined on an order 6 triangulation.

Source Code:

Last revised on 25 December 2018.