Go to CCP Homepage Go to Materials Page Go to Differential Equations Materials Go to Table of Contents
Go Back One Page Go Forward One Page

MATLAB Tutor

Part 4: Saving your work

If you want to save the work you do in a MATLAB session, you must create a diary file. This file will contain a complete transcript of everything you type into the computer, and everything the computer responds. Later, you can edit it with any word processor.

To start a diary file called ‘Lab1.txt’ on the diskette in drive a, for instance, you would type

diary a:Lab1.txt

and press Enter. You probably won’t see anything happen, but the computer is keeping track of your work.

You can suspend saving your work at any time by typing

diary off

Typing diary on will go back to saving your work at the bottom of your previous diary file. If diary is on when you quit MATLAB, your diary file will be automatically closed.


When you quit your MATLAB session, the values of all your variables are lost. Your diary file only keeps a log of what has appeared on your screen, not stored values of variables. If you want, before you quit MATLAB, you can save the current values of variables into a file to use in a future session. The following command would save the values into a file called myfile:

save myfile

The values of all the variables in your workspace will be saved in binary form, unreadable by humans, into a file called myfile.mat in your working directory. In a future MATLAB session, to load all these variable values into the new session, use the command:

load myfile



Go to CCP Homepage Go to Materials Page Go to Differential Equations Materials Go to Table of Contents
Go Back One Page Go Forward One Page


| CCP Home | Materials | Differential Equations | Module Contents | Back | Forward |

modules at math.duke.edu Copyright CCP and the author(s), 2000