Home

How to Manage Data with MATLAB’s Current Folder Window

|
Updated:  
2016-03-26 08:22:47
|
From The Book:  
MATLAB For Dummies
Explore Book
Buy On Amazon

The Current Folder window really does show the current MATLAB folder listed in the Address field. You don’t see anything because the current folder has no files or folders to display. However, you can add files and folders as needed to store your MATLAB data.

Permanently changing the default folder

The default folder is the one that MATLAB uses when it starts. Setting a default folder saves you time because you don’t have to remember to change the current folder setting every time you want to work. If you have your default folder set to the location from which you work most of the time, you can usually get right to work.

If you want to permanently change the default folder so that you see the same folder every time you start MATLAB, you must use the userpath() command. Even though this might seem like a really advanced technique, it isn’t hard. Simply type userpath(‘C:MATLAB') in the Command window and press Enter. You need to change the path to wherever you placed the downloadable source.

To see what the default path is for yourself, type userpath and press Enter. MATLAB displays the current default folder.

Creating a new folder

Organizing the files that you create is important so that you can find them quickly when needed. To add a folder to the Current Folder window, right-click any clear area in the window and choose New Folder from the context menu. MATLAB creates the new folder for you. Type the name you want to use for the new folder and press Enter.

Running a saved script

You can run any script by right-clicking its entry in the Current Folder window and choosing Run from the context menu. When you run a script, you see the script name in the Command window, the output in the Workspace window, and the actual command in the Command History window.

Saving the current workspace to disk

Sometimes you might want to save your workspace to protect work in progress. The work may not be ready to turn into a script, but you want to save it before quitting for the day or simply to ensure that any useful work isn’t corrupted by errors you make later.

To save your workspace, click Save Workspace in the Variable group of the Toolstrip’s Home tab. You see a Save to MAT-file dialog box that looks similar to the Select File for Save As dialog box. Type a filename for your workspace, such as FirstWorkspace.mat, and click Save to save it.

Workspaces use a .mat extension, while scripts have a .m extension. Make sure that you don’t confuse the two extensions. In addition, workspaces and scripts use different icons so that you can easily tell them apart in the Current Folder window.

About This Article

This article is from the book: 

About the book author:

Jim Sizemore is Professor of Physics and Engineering at Tyler Junior College. For over 25 years he s worked in the semiconductor and software industries as a process engineer, device physicist, and software developer and has been teaching college physics, engineering, and math for the last 13 years.

John Paul Mueller is a freelance author and technical editor. He has writing in his blood, having produced 100 books and more than 600 articles to date. The topics range from networking to home security and from database management to heads-down programming. John has provided technical services to both Data Based Advisor and Coast Compute magazines.