Load variables from file into workspace
load(
loads
data from filename
)filename
.
If filename
is a MAT-file, then load(filename)
loads
variables in the MAT-File into the MATLAB® workspace.
If filename
is an ASCII file, then load(filename)
creates
a double-precision array containing data from the file.
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.
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
.