saving everything in the workspace
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, the save comand only saves the variables, handles, etc. However I need to save everything in the workspace including struct, doubles, etc...everything.
Also, once everything is saved I would like to load everything exactly the way it was saved. Would all this be possible?
Thank you
9 comentarios
Image Analyst
el 30 de Mayo de 2013
At the point that you call save() you should have hObject, eventdata, handles, and filename, and pathname as the only variables in existence. It's a mystery to me why filename and pathname do not get saved into the mat file. The help file says "save(filename) stores all variables from the current workspace in a MATLAB® formatted binary file (MAT-file) called filename." So, if like you say, only the first three variables are being stored and able to be recalled and the latter two aren't, I'd call the Mathworks about it. But first see if you can open that mat file in any other script or from the command line and see what gets returned.
Respuesta aceptada
per isakson
el 31 de Mayo de 2013
Editada: per isakson
el 31 de Mayo de 2013
You can use the command or the function syntax. If the variable names are the values of string variables then command syntax cannot be used.
Try
>> save_test
it prints to the command window
Name Size Bytes Class Attributes
a 1x1 8 double
where
function save_test
a = 1;
b = 2;
Save_Xallback
whos -file save_test.mat
end
function Save_Xallback
evalin( 'caller', 'save save_test.mat a' );
end
.
Answer to the first comment:
The above is a hint rather than a complete answer. I don't exactly understand what you want to achieve. Variables of which workspace do you want to save? Outline a simple example in code. Some basics:
Workspaces
- there is the base workspace and
- each function has it own workspace
Callbacks
- callbacks are "called" from the base workspace; the caller is the base. Thus, evalin( 'caller', ... ) and evalin( 'base', ... ) are equivalent in a callback function.
Command and Function syntax
- save myfile.mat a
- save( 'myfile.mat', 'a' )
"I'm thinking ... : evalin('caller','save save_test.mat variables')"
- The variables of which workspace do you want to save?
- Why did you introduce the function, Save_Callback?
"... save the workspace while in any function?"
- there is no "the workspace". There are many.
I believe it is difficult to save the complete "state" of a running Matlab program. Special cases maybe.
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!