A figure created in script "x" is being automatically deleted (didn't used to) when script "x" calls another script.

조회 수: 2 (최근 30일)
A script contains the following code:
globa hdata
hdata = figure('visible', 'off', 'tag', 'DataStore');
The goal is to use this "hidden" figure as a global space for passing data among several GUIs (designed via GUIDE).
Following the hdata assignment there are numerous occurrences of lines containing the general form:
setappdata(hdata, <string variable>, <data variable>);
This loads data into the "hidden" figure.
The final line in the script is the name of another .m file (a script that lauches a GUI).
In the "GUI" script is another global declaration for hdata (just like above).
The "GUI" script errors out on the following line of code:
x = getappdata(hdata, <string variable>);
Where <string variable> is one of the same string variables used in the setappdata() function mentioned previously.
After some debugging I found the error occurs because the "hidden" figure is being deleted when the "GUI" script is called. This did not happen in the past. However, I am now using MATLAB R2019b, but the code in question was developed under R2012 (if that helps).
Any tips or advice would be most appreciated.

답변 (1개)

Steven Lord
Steven Lord 2021년 9월 30일
The GUI that deletes the figure probably calls close. You can protect the figure against closing somewhat by changing its HandleVisibility property to 'callback' and/or you could change its CloseRequestFcn property. Neither will guarantee the figure cannot be closed (the close function has options to ignore HandleVisibility and the CloseRequestFcn if they are specified) but it would help.
Alternately if one of your GUIs is a "hub" or main GUI, why not store the data there?

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by