Save base workspace MAT file from GUI

3 Ansichten (letzte 30 Tage)
Jason
Jason am 18 Nov. 2011
Guys -
I'm writing a GUI in which I'd like to put a pushbutton to save the entire base workspace to a .mat file. Problem is I don't know how to do that from the GUI subfunction workspace. Can anyone point me to the right approach or write a couple lines I can put in the pushbutton's callback function to save the base workspace as .mat?

Akzeptierte Antwort

Jan
Jan am 18 Nov. 2011
I do not think, that this method have enough control over what is written. But if you really want to save the base workspace to a MAT file:
evalin('base', 'save(''FileName.mat'')');
  3 Kommentare
Jan
Jan am 18 Nov. 2011
FileName = 'test.mat';
evalin('base', ['save(''', FileName ''')']);
Jason
Jason am 19 Nov. 2011
Thanks Jan, you rock!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Naz
Naz am 19 Nov. 2011
Here is what I would do: for saving a particular set of variables in the struct you can create a struct and save it:
structDATA=struct('your1var',handles.your1var,'your2var',handles.your2var);
save ('filename', 'structDATA');
If you want to save all the variables from handles, then just do:
save ('filename', 'handles');
I hope this will work
  2 Kommentare
Jason
Jason am 19 Nov. 2011
Thanks Naz.
Mohamed Sarillee
Mohamed Sarillee am 31 Jan. 2013
thank you.... :-)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by