Skip to Main Content Skip to Search
Product Documentation

Working with Files and Folders

Viewing Folder Contents

You can view information about folders from the MATLAB Desktop like you can from operating system windows. You can also type commands to describe files as you can from a command shell. For a summary of MATLAB functions you can use, see Using Functions to Get Details About Files and Folders .

The principal Desktop tool for working with files and folders is the Current Folder browser. Like other Desktop components, you can dock the Current Folder browser or open it as a separate window. The Current Folder browser displays details about files in your current folder and within the hierarchy of the folders it contains. You can modify the kinds of information it displays to suit your needs, for example by reordering or deleting specific columns of information.

The Current Folder browser:

The following sections explain what you can do with the Current Folder browser and how to use it.

Opening the Current Folder Browser

Open the Current Folder browser by selecting Desktop > Current Folder from the MATLAB desktop. By default (when you start MATLAB for the first time) the Current Folder browser is docked on the left side of the desktop.

The Current Folder browser shows the full path to the current folder in the navigation bar, and shows the contents of the current folder in a pane underneath the bar.

Change the size, location, or other characteristics of the Current Folder browser as you would any tool on the MATLAB desktop. See Desktop. You also can undock it from the desktop.

Image of Current Folder browser.

View the contents of subfolders and zip files by clicking the + (expand) button. Double-clicking a subfolder displays its contents, and makes that folder the current folder. Right-clicking a zip file and then selecting Extract extracts the files from it.

MATLAB might not be able to run files in the subfolders. See Making Files and Folders Accessible to MATLAB.

Preferences for the Current Folder Browser

You can set preferences for aspects of the Current Folder browser. Access these preferences by selecting File > Preferences > Current Folder. The preferences are:

Refreshing the List of Files

When files and folders are created, deleted, or changed outside of MATLAB, the Current Folder browser automatically reflects the changes. When you access files on a network, frequent refreshing of the Current Folder browser can slow performance in MATLAB. If this seems to be a problem, try improving the performance by changing how frequently refreshing occurs using the Current Folder Refresh preference:

  1. Select File > Preferences > Current Folder.

    By default, the Auto-refresh view from file system option is on, with an update time of 3 seconds. Every 3 seconds, the Current Folder browser checks for and reflects changes made from programs and tools other than MATLAB.

  2. Try to improve responsiveness by either:

    • Increasing the Number of seconds between auto-refresh.

    • Clearing the Auto-refresh view from file system check box to turn off the feature.

  3. Click OK.

To manually refresh the view at any time:

  1. Right-click in the list area of the Current Folder browser.

  2. Select Refresh from the context menu.

Viewing Hidden Files and Folders

The operating system, by default, hides certain files and folders from system file browsers and file-listing commands. The Current Folder browser can display hidden files and folders. You control this in different ways on different operating systems.

On Microsoft Windows platforms, the Current Folder browser follows the Windows preference for showing hidden files. To set or change the Windows preference:

  1. Open Windows Explorer.

  2. Select Tools > Folder Options.

  3. Click the View tab.

  4. Under Advanced settings, select Show hidden files and folders.

On other platforms, specify the behavior using Current Folder preferences:

  1. Select File > Preferences > Current Folder.

  2. Specify the setting for Hidden files and folders.

Controlling the Appearance of Files Inaccessible to MATLAB

MATLAB cannot access files if they are not on the search path or, in some cases, if they are in a private folder. By default, the Current Folder Browser dims the display of files and folders inaccessible to MATLAB. Furthermore, if you hover over a dimmed file, a tooltip provides information on why that file is inaccessible. If you disable this feature, the Current Folder browser displays all files and folders as undimmed and provides no tooltips regarding their availability to MATLAB.

To customize this feature:

  1. Select File > Preferences > Current Folder.

  2. Select the Indicate inaccessible files check box to enable this feature; deselect it and skip to step 5 to disable this feature.

  3. Move the Text and icon transparency slider to adjust the level of dimming.

    View the region below the slider to preview how your choice will affect the appearance of files in the Current Folder browser.

  4. Select Show tooltip explaining why files are inaccessible to enable tooltips; deselect it to disable them.

  5. Click OK.

For more information, see Private Folders and What Is the Search Path?.

Using Functions to Get Details About Files and Folders

In the Command Window, you can list files, move to another folder, create folders, and delete files and folders. Most of these commands work like they do in an operating system command shell, but have different options. For example, some of the commands can return an argument in the form of a structure containing file information. The following table lists some of the actions you can perform with commands.

To...Use This Function
Change your current foldercd
Get the name, date, and size for a file or folderdir or ls
Get and set the read-write status and other attributes for a file or folderfileattrib
Separate a path name into folder and file namefileparts
Build a file or folder name from partsfullfile
Determine if a string corresponds to a folderisdir
Move a file to a different foldermovefile
Create a foldermkdir
Delete a filedelete
Delete a folderrmdir
List files specific to MATLABwhat

Using the Current Folder Browser

The Current Folder browser lists details about files and folders in columns, beneath file and folder names, and in the details panel. Any file that is modified in the Editor, but not yet saved has an asterisk (*) next to it in the Current Folder browser. The browser displays columns for Size, Date Modified, Type, and Description. You can modify the information it displays. You also use this tool to perform operations on files and folders, such as moving, compressing, renaming, creating, and deleting them.

Customizing the Column Display

You can show and hide columns, change their order, and adjust the date format in the Current Folder browser.

To Specify the Columns to Display.  

  1. Select View > Show or right-click on any column header.

  2. Select the columns to show. Clear the columns to hide.

In addition, consider:

To Modify Columns.  

To Change the Date Format.  MATLAB uses your operating system's short date format to display dates in the Current Folder browser and the Command History window. To change the date format, for instance from MM/DD/YYYY to DD/MM/YYYY, (where MM is the numerical value for the month, DD is the numerical value for the day, and YYYY is the numerical value for the year):

  1. Change the short date format for your operating system. For instructions, see your operating system documentation.

  2. Refresh the date display by either restarting MATLAB or doing the following:

    • In the Current Folder browser, right-click, and then choose Refresh from the context menu.

      Dates refresh and use the new format.

    • In the Command History window, right click, and then choose Clear Command History from the context menu.

      The window clears. MATLAB specifies new dates in the window using the new format.

Viewing File Descriptions

Show or hide descriptions in the Current Folder browser by selecting View > ShowDescription.

Descriptions appear in gray text beneath the name of the file or folder. When the Current Folder browser window is wide enough, descriptions display on the same line as file names. The Current Folder browser shows descriptions only for files and folders that are relevant to products from MathWorks. How the Current Folder browser gets the description depends on the type of item:

To provide descriptions for your own files and folders, see Add Help for Your Program Files.

Viewing File Details Without Opening Files

Display file details without opening a file by selecting the file, and then clicking the up arrow button on the lower right corner of the Current Folder browser. The details panel expands.

File and Folder Details.   When you select a file or folder, the details panel displays more information about that file or folder, if possible. For example, if you select a MATLAB code file, the details panel shows the functions or subfunctions which that the file contains.

Image File Details.   When you select a JPEG, JPG, BMP, WBMP, PNG, or GIF image, the details panel displays a thumbnail of the image and lists its width and height in pixels. To open the Import Wizard, double-click the thumbnail.

Viewing Unsaved File Changes.  When you select a file that is currently open in the Editor and that contains unsaved changes, an asterisk (*) appears after that file name. The Current Folder browser columns reflect the content of the unsaved file. For instance, if you open a file, change it from a script to a function, and modify the H1 line, then the icon, type name, and description update in the Current Folder browser.

The preview in the details panel also reflects the unsaved file content, not the content on disk. For instance, in the following example, PropertyTwo exists in the modified MyClass.m file, but not the MyClass.m file on disk.

Viewing and Going to Elements within a MATLAB Program File.  The details panel lists these elements when you selected a file with a .m extension:

To open the file in the Editor, scroll to the start of the element in the details panel and double-click the element.

Viewing and Loading MAT-File Variables.  Use the details panel to view the name, class, and value of all variables in the selected MAT-file. To load a variable into the workspace, select it in the details panel and drag it to the Workspace browser. The folder containing the MAT-file does not need to be on the search path for you to load it in this way.

Viewing Help for a MATLAB Program File

From the Current Folder browser, you can view help for a file that has a.m extension and is in the current folder or in a folder on the search path:

  1. Right-click the file.

  2. Select View Help from the context menu.

    The reference page, if it exists, opens in the Help browser. Otherwise, help comments from the beginning of the file, if any exist, display in the Help browser.

Sorting and Grouping Files and Folders

Organize, find, and manage the files and folders you use with MATLAB by sorting and grouping items.

By default, sorting is by Name and grouping is off.

Regardless of the sorting and grouping options selected, the Current Folder browser lists folders and files separately.

Sorting Items.  To change the order of items listed, sort by column:

  1. Select View > Sort By.

  2. Select the name of the column to sort by.

Alternatively, click the column header by which you want to sort. Click it again to reverse the direction of sorting.

Grouping Items.  To see related items listed together, group them:

  1. Select View > Group By.

  2. Select Type, Size, or Date Modified.

Each group has a label. To hide the items in a group, click the collapse button (–) next to the label.

To turn off grouping, select View > Group By > Stop Grouping.

Using Sorting and Grouping Together.  You can sort and then group, or group and then sort.

After grouping items, sort using different criteria. The sort applies to the groups and to items within each group.

The following figure illustrates grouping by type, with some groups collapsed. The sort order is descending by date

Viewing Only One Type of File.  To view only files of a certain type (for example, files having a .m extension) use a simple search. See Simple Search for File and Folder Names in the Current Folder Browser.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS