Graphics Previous page   Next Page

Generating an M-File to Recreate a Graph

You can generate an M-file from a graph, which you can then use to regenerate the graph. This approach is a useful way to generate M-code for work you have performed with the plotting tools. To use this option,

  1. Select Generate M-file from the File menu.
  1. MATLAB displays the generated code in the MATLAB Editor.

  1. Save the M-file using Save As from the Editor File menu.

Running the Saved M-File

Most of the generated M-files require you to pass in data as arguments. The M-file assumes you are using the same data originally used to create the graph.

Comments at the beginning of the M-file state the type of data expected. For example, the following statements illustrate a case where three input vectors are required.

See Example -- Generating M-Code to Reproduce a Graph for another example.


Previous page  Printing Figures Data Exploration Tools Next page

© 1994-2005 The MathWorks, Inc.