When you load data from a file, there might be conflicts with functions on the
path, which include MATLAB built-in functions. Consider the following function
in which myData.mat
contains the variable
theta
.
function z = myFun
load myData.mat
z = theta(1);
end
If there is a function theta
on the MATLAB path, the
variable theta
conflicts with the function
theta
. To avoid possible conflict, specify the
theta
variable in the call to
load
.
function z = myFun
load myData.mat theta
z = theta(1);
end
To avoid conflict with functions on the path, load data from a file using one of these syntaxes.
Specify variables to load. For example,
load mydata.mat a b c
load('mydata.mat','a','b','c')
Specify an output argument to load data into a structure or array. For example,
S = load('mydata.mat')
load
.