load
Load variables from file into workspace
Syntax
Description
load(
loads
data from filename
)filename
.
If
filename
is a MAT-file, thenload(filename)
loads variables in the MAT-file into the MATLAB® workspace.If
filename
is an ASCII file, thenload(filename)
creates a double-precision array containing data from the file.
Note
Security Considerations: The
load
command might execute code contained in the MAT-file as it
initializes variables. Avoid calling load
on untrusted
MAT-files.
load(
treats filename
,'-mat')filename
as
a MAT-file, regardless of the file extension.
load
is the
command form of the syntax. Command form requires fewer special characters.
You do not need to type parentheses or enclose input in single or
double quotes. Separate inputs with spaces instead of commas. filename
For example, to load a file named durer.mat
,
these statements are equivalent:
load durer.mat % command form load('durer.mat') % function form
You can include any of the inputs described in previous syntaxes.
For example, to load the variable named X
:
load durer.mat X % command form load('durer.mat','X') % function form
Do not use command form when any of the inputs, such as filename
, are
variables or strings.
Examples
Input Arguments
Output Arguments
Limitations
When working with remote data,
load
does not support treating the input file as an ASCII file.
Algorithms
If you do not specify an output for the load
function, MATLAB creates
a variable named after the loaded file (minus any file extension).
For example, the command
load mydata.dat
reads data into a variable called mydata
.
To create the variable name, load
precedes
any leading underscores or digits in filename
with
an X
and replaces any other nonalphabetic characters
with underscores. For example, the command
load 10-May-data.dat
creates a variable called X10_May_data
.
Extended Capabilities
Version History
Introduced before R2006a
See Also
clear
| importdata
| matfile
| regexp
| save
| Import Tool | whos