# load

## Purpose

Retrieve variables from disk.

## Synopsis

    load
    load filename
    load filename.extension

## Description

`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

    str = 'fname.mat'
    load (str)

retrieve the variables from the binary file `'filename.mat'`.

## Examples

If the file `sample.dat` contains four lines of numeric text

        1.1    1.2    1.3
        2.1    2.2    2.3
        3.1    3.2    3.3
        4.1    4.2    4.3

the command

    load sample.dat

produces a 4-by-3 matrix named `sample` in the workspace.

## Algorithm

The External Interface Guide discusses the structure of MAT-files in detail. The External Interface Library contains C and FORTRAN callable routines to read and write MAT-files from external programs.

## See Also

    fprintf, fscanf, save, spconvert

(c) Copyright 1994 by The MathWorks, Inc.