Skip to content

load

Load variables from a file into the workspace.

load
load(filename)
load(filename, var1, var2, ...)
S = load(filename)

Loads variables from a .mat (or compatible) file. Without an output assignment, the variables are placed directly in the current workspace. With output assignment, returns a struct whose fields are the loaded variables.

Without a filename, defaults to matlab.mat. Specifying variable names loads only those.

load % loads matlab.mat into workspace
load('data.mat')
S = load('data.mat'); % capture into struct
  • save — Save workspace variables to a file.
  • importdata
  • csvread — Read a CSV file into a matrix.
  • xlsread — Read data from an Excel (.xlsx) file.