GUI function data to workspace and to file

조회 수: 1 (최근 30일)
László Arany
László Arany 2012년 6월 10일
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