In the absence of an explicit assignment to an identifier, MATLAB interprets
an identifier as a variable if you index into it with a colon, curly braces, or
the end
keyword. If you use the identifier in a function
handle or in command syntax, MATLAB interprets it as a function.
To ensure MATLAB correctly interprets identifiers as variables, explicitly declare or assign to variables. For example, consider the following function.
function myFun ()
load data.mat; % Loads all variables, including x.
disp(x(:))
end
In myFun
, MATLAB interprets x
as a
variable because it is indexed with a colon in the disp
call.
However, that might change in a future release. To ensure x
is used as a variable, explicitly define it. For example, load the specific
variable x
or initialize it.
function myFun ()
|
function myFun ()
|