Development Environment    

Opening, Running, and Viewing the Content of Files

Opening Files

You can open a file using the open feature of the Current Directory browser. The file opens in the tool associated with that file type.

To open a file, select one or more files and perform one of the following actions:

The files open in the appropriate tools. For example, the Editor/Debugger opens for M-files, and Simulink opens for model (mdl) files.

To open any file in the Editor, no matter what type it is, select Open as Text from the context menu. One exception is P-files (.p), which you cannot open.

You can also import data from a file. Select the file, right-click, and select Import Data from the context menu. The Import Wizard opens. See Importing and Exporting Data for instructions to import the data.

Function Alternative.   Use the open function to open a file into the tool appropriate for the file, given its file extension. Default behavior is provided for standard MATLAB file types. You can extend the interface to include other file types and to override the default behavior for the standard files. For name.ext, open performs the following actions.

File Type
Extension
Action  
Figure file
fig
Open figure name.fig in a figure window.
HTML file
html
Open HTML file name.html in the Help browser.
M-file
m
Open M-file name.m in the Editor.
MAT-file
mat
Open MAT-file name.mat in the Import Wizard.
Model
mdl
Open model name.mdl in Simulink.
P-file
p
Cannot open P-files.
PDF file
pdf
Open the PDF file name.pdf in the installed PDF reader, for example, Adobe Acrobat.
Variable
not applicable
Open the numeric or string array name in the Array Editor; open calls openvar.
Other
custom
Open name.custom by calling the helper function opencustom, where opencustom is a user-defined function.

To view the content of an ASCII file, such as an M-file, use the type function. For example

displays the contents of the file startup.m in the Command Window.

Running M-Files

To run an M-file from the Current Directory browser, select it, right-click, and select Run from the context menu. The results appear in the Command Window.

Viewing Help for an M-File

You can view help for the M-file selected in the Current Directory browser. From the context menu, select View Help. The reference page for that function appears in the Help browser, or if a reference page does not exist, the M-file help appears.

You can view the M-file help in the Current Directory browser--for instructions, see Preferences for the Current Directory Browser.


  Creating, Renaming, Copying, and Removing Directories and Files Finding and Replacing Content Within Files