MATLAB Function Reference | ![]() ![]() |
Syntax
open('name')
Description
open('name')
opens the file name
, where the specific action upon opening depends on the type of file that name
is.
name |
Action |
variable |
Open array name in the Array Editor (the array must be numeric); open calls openvar |
figure file (*.fig ) |
Open figure in a figure window |
HTML file (*.html ) |
Open HTML document in Help browser |
M-file (name.m) |
Open M-file name in M-file Editor |
model (name.mdl ) |
Open model name in Simulink |
p-file (name.p ) |
Open the corresponding M-file, name.m , if it exists, in the Editor |
other extensions (name.custom ) |
Open name.custom by calling the helper function opencustom , where opencustom is a user-defined function. |
Behavior When name Does Not Have an Extension
If name
does not contain a file extension, open
opens the object returned by which
(name)
, where name
is a variable, function, or model. If there is no matching helper function found, open
uses the default editor.
If name
does not contain a file extension and there is a matching filename without an extension, open
opens the file in the editor. If it does not find a matching file without an extension, open
looks for an M-file with the same name on the path, and if found, opens it in the editor.
To handle a variable, open
calls the function openvar
.
Create Custom open
Create your own opencustom
functions to change the way standard file types are handled or to set up handlers for new file types. open
calls the opencustom
function it finds on the path.
Example 1 - No File Extension Specified
If testdata
exists on the path,
open('testdata')
If testdata
does not exist, but testdata.m
is on the path,
open('testdata')
opens testdata.m
in the editor.
Example 2 - No File Extension Specified, M-file and Model Files Present
If testdata
.m and testdata.mdl
are both present on the search path, and you type
open('testdata')
testdata.mdl
opens in Simulink. This is because model files take precedence over M-files, which you can see by typing
which('testdata')
It returns the file that takes precedence, in this case
testdata.mdl
Example 3 - Customized open
open('mychart.cht')
calls opencht('myfigure.cht')
, where opencht
is a user-created function that uses .cht
files.
See Also
hgload
, hgsave
, load
, openvar
, save
, saveas
![]() | ones | openfig | ![]() |