MATLAB: Function variables not saved to workspace

functionvariable

Hi,
I define variables in one function and want to pass them off to another function. If I stop the function right before the function ends (at y), x and y are in my workspace, but once the function ends, x and y are gone, and not saved to my workspace.
function [x,y]=myfunc()
x=2;
y=3;
end

Best Answer

Call the function as:
[x,y]=myfunc()
and both should be in your workspace.