checking if struct exists, GUI related

2 ビュー (過去 30 日間)
Steffan
Steffan 2011 年 5 月 13 日
編集済み: sina kosari 2018 年 1 月 19 日
Hello
at the moment I am working with a data structure, this structure is stored in appdata in a certain way.
in my mainGui I create a base cell array called plotTypeData, this is stored as
plotTypeData = cell(1,6);
setappdata(gcf, 'plotTypeData', plotTypeData);
setappdata(0, 'hMainGui', gcf);
in the mainGui openingfcn.
Now to why I need to check if the a structure exists: I have 6 other GUIs which are able to call the plotTypeData cell and alter it, when a secondary GUI have altered the contents of plotTypeData, it will store or update it as follows
setappdata(0, 'plotTypeData', plotTypeData);
The real problem occur, as one might have guessed, when a secondary GUI needs to get the data from plotTypeData. Because if a secondary GUI have not stored the plotTypeData in the root directory it is necessary to retrieve it from the mainGui handle, hMainGui. So what I am trying to figure out, is a way to check whether the plotTypeData struct exists in the root directory or not, and act accordingly. It needs to be mentioned that within plotTypeData cell are stored, making plotTypeData become a 1x1 struct.
in the root directory. This is done to ensure that plotTypeData is reachable by all GUIs.
any suggestions?
best regards
Steffan

採用された回答

Robert Cumming
Robert Cumming 2011 年 5 月 13 日
using
getappdata
without specifying the variable name will return a structure with all data as fields in it.
  5 件のコメント
Steffan
Steffan 2011 年 5 月 16 日
works like a charm, thanks :)
sina kosari
sina kosari 2018 年 1 月 19 日
編集済み: sina kosari 2018 年 1 月 19 日
:) :) :) :) :) :) :) :) thanks :) :) :) :) :) :) :) :)

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2011 年 5 月 13 日
See the function: isappdata
  3 件のコメント
Arturo Moncada-Torres
Arturo Moncada-Torres 2011 年 5 月 16 日
Give him a vote then ;) !
Steffan
Steffan 2011 年 5 月 16 日
done ;)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by