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

 Akzeptierte Antwort

Star Strider
Star Strider am 10 Mär. 2020

2 Stimmen

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

4 Kommentare

Qiana Curcuru
Qiana Curcuru am 10 Mär. 2020
that works thanks!
Star Strider
Star Strider am 10 Mär. 2020
As always, my pleasure!
Andrew Webster
Andrew Webster am 14 Okt. 2021
Thank you SOOOOO much. save me an hour headache
Star Strider
Star Strider am 14 Okt. 2021
@Andrew Webster — My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by