load
load filename
loadfilename.extension
load
and save
are the MATLAB commands to retrieve and store variables on disk. They can also import and export ASCII data files.
MAT-files are double-precision binary MATLAB format files created by the save
command and readable by the load
command. They can be created on one machine and later read by MATLAB on another machine with a different floating-point format, retaining as much accuracy and range as the disparate formats allow. They can also be manipulated by other programs, external to MATLAB.
load
, by itself, loads all the variables saved in the file 'matlab.mat'
.
load
filename
retrieves the variables from 'filename.mat'
.
load filename.extension
reads the file filename.extension
, which can be an ASCII file with a rectangular array of numeric data, arranged in m
lines with n
values in each line. The result is an m
-by-n
matrix with same name as the file with the extension stripped.
The ASCII data must be in matrix form, or MATLAB may be unable to use the data when you load it.
You can also load a file whose name is stored in a variable. The commands
retrieve the variables from the binary filestr = 'fname.mat'
load (str)
'filename.mat'
.
sample.dat
contains four lines of numeric text
the command1.1 1.2 1.3
2.1 2.2 2.3
3.1 3.2 3.3
4.1 4.2 4.3
produces a 4-by-3 matrix namedload
sample.dat
sample
in the workspace.
fprintf
,fscanf
,save
,spconvert
(c) Copyright 1994 by The MathWorks, Inc.