From: Zhelyazko on
Every object in Matlab has a UserData Property.
Where you can save information.
For Example you can save the current y values in the figure
UserData.
Something like that.

f=figure;
y=1:10;
set(f,'userData',y);
sampleFcn;


%some function taht is going to get this data
function sampleFcn
f=gcf;
y=get(f,'UserData');
display(y);