GUI function data to workspace and to file

3 次查看(过去 30 天)
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ó

采纳的回答

László Arany
László Arany 2012-6-17
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by