function variables not saved to workspace

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2020-3-10
Call the function as:
[x,y]=myfunc()
and both should be in your workspace.
  4 个评论
Andrew Webster
Andrew Webster 2021-10-14
Thank you SOOOOO much. save me an hour headache

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by