GUI function data to workspace and to file

1 view (last 30 days)
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ó

Accepted Answer

László Arany
László Arany on 17 Jun 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.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!