This code utilizes a time marching method for solving the Cahn-Hilliard equation that is unconditionally stable (paper). Without such a method, solving the Cahn-Hilliard equation for long times is a very slow process. To run the code, either save the code in a .m file and execute that file in Matlab (it doesn't need any additional arguments) or cut and paste.
The code generates a movie of the solution, so don't raise a window over the figure or movie will not work properly. The movie has 25 frames, and the code takes 250 time steps.
The data is presented with four subplots, the top two plots show the solution as a function of space. The lower left plot shows a cross section of the solution, and the lower right plot shows a portion of the power spectrum of the solutions cosine transformation.
By studying the code, you should be able to use similar ideas in your applications.
David Eyre