Most recent answer
When you run MATLAB® code that returns an output without specifying an output argument,
MATLAB creates the ans
variable and stores the output
there. Changing or using the value of ans
in a script or
function is not recommended, as the value can change frequently.
ans
is specific to the current workspace. The base workspace
and each function workspace can have its own instance of ans
.
For more information, see Base and Function Workspaces.