GUI function data to workspace and to file

1 visualización (últimos 30 días)
László Arany
László Arany el 10 de Jun. de 2012
I have a GUI which has a function which runs a few loops and calculates data into matrices. These data are then displayed in a plot.
However, I want the data for the plot to be accessible by a "Save plot data to file" button. My idea is to put the data from within the function that makes the plot to the workspace, and then the Callback of the "Save plot data to file" button can save the data to a file anytime from the workspace.
The problem is, I can't get the data from within a GUI callback function to workspace. Is there a simple solution for this? Do I need a global variable?
Any other ideas about how to solve the problem of saving the data to file would also be welcome. Thank you in advance, László

Respuesta aceptada

László Arany
László Arany el 17 de Jun. de 2012
I could finally figure it out. You can save the data in the handles of the given GUI. So for example if your GUI is named "MyGUI" and you want to save the matrix M, then you can save data within a fuction as the following:
handles.MyMatrix = M; guidata(MyGUI,handles);
This will allow you to reach the values stored in M from any function, and then you can plot it, save it.

Más respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by