function variables not saved to workspace

조회 수: 7 (최근 30일)
Qiana Curcuru
Qiana Curcuru 2020년 3월 10일
댓글: Star Strider 2021년 10월 14일
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
Star Strider
Star Strider 2021년 10월 14일
@Andrew Webster — My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by