1. General Information

Working with a Flash drive

While you are working in the VDI, any files that you create which need to be accessed should be saved on to the VDI's hard drive. However, at the end of a session, when you log off the computer, you will lose all such files that you have saved unless you save them to disk or flash drive.

Soon you will be constructing M-files. These will be explained in more detail later, but previous information has already signalled that there are two quite different types, namely script M-files and function M-files. A script M-file will contain a sequence of MATLAB commands designed to solve a particular problem. A function M-file is of a different form, and enables you to extend the list of standard MATLAB functions by constructing, naming and saving your own functions.

As long as you are in the MATLAB environment you can access all of the M-files which constitute the professional version no matter on which disk drive or flash drive you are working. However, if you need to access an M-file which has been stored on a floppy disk or flash drive, you must change your working directory to that drive. After the >> prompt, type in cd a: (or another letter, instead of a, for the appropriate drive) which changes the directory to the a: drive (the flash drive). Then, to get a list of the files that are stored on the disk or flash drive, you can enter dir after the prompt.

Saving M-files to a storage device

Let us assume you have an active window (such as the M-File “Editor/Debugger” window) containing an M-file, and you have placed a disk in the disk drive.

Click on File, then on Save As....

In the Save in: box, specify the location where you want this M-file saved. If you merely wish to save it during this session, you must specify the e: Scratch drive on the computer.

If you wish to save it on your flash drive, you need to choose the a: or another appropriate drive.

In the File name: box, you must enter the name you have chosen for this M-file. All MATLAB M-files must have names that finish with .m such as test1.m or project.m or myfunctn.m or prac3wk8.m, etc. NOTE: every year some students cause all sorts of anguish to themselves by selecting a name for their M-file which happens to already be the name of one of MATLAB ’s own M-files. This must not be done! For example, do not name your M-file sin.m because this is where the trigonometric function sin x is stored in MATLAB. Never name your M-file solve.m because that is the name of a file in the Symbolic Math Toolbox which solves an equation. As there are hundreds of M-files in MATLAB, you need to be careful when naming your own.

Once you have selected a name, click on Save.

Thereafter, if you make any changes to this M-file, and you need to save those changes, you click on File, then on Save in the “Editor/Debugger” window. Alternatively, you could click on the “Save” icon.

 

Loading M-files from a storage device

After the MATLAB prompt, change directory to the floppy. Type in dir just to check what is on the floppy disk or flash drive. Click on File, then Open and double click the required M-file. This will open the file inside the “Editor/Debugger” window where additions and corrections can be made, and later saved as described above.