Retaining data on GUIs on GUIDE
1 回表示 (過去 30 日間)
古いコメントを表示
I am passing data from one GUI to the other using
H = findall(0,'tag','editbox1tag');
set(handles.editbox2tag,'string',get(H,'string'))
But this won't let me change it to something else. Whenever i enter a value it reverts back to the called value. I have to use a separate push button now to call the value and i input the user defined data separately. But this has made the GUI messy. And it works only when the first GUI is open. I am actually manipulating data in one GUI and calling that data on another - second GUI. I want the manipulated value already called when i open the second GUI without having to have the first GUI open. Furthermore the manipulated value is being called in multiple other GUIs, i want it to update itself in the other GUIs according to the new parameters.
Please help anyone.
0 件のコメント
回答 (1 件)
Paul
2012 年 3 月 16 日
I think passing information with the findall can be a bit dangerous. What if you have multiple instances of the first GUI running? I wrote a little example. Here you pass in the function handle of first GUI the first time the function is called. The values are intialized. Then you just use it as a structure to get the data you want. I would call this function with temp = getData(h) where h is the handle to your main figure. Then temp.getString1() returns a certain type or data, etc. This allows you to destroy the first GUI but some of its contents have been saved. Obviously, there are many variations on this theme and I don't know if this will help in your case.
function myData = getData(varargin)
if ~isempty(varargin)
h = varargin{1};
pushbuttonString = get(findobj(h,'tag','pushbutton1'),'String');
end
myData.string1 = @getString1;
myData.string2 = @getString2;
myData.string3 = @getString3;
function out = getString1()
out = 'incredibly important string';
end
function out = getString2()
out = 'another incredibly important string';
end
function out = getString3()
out = pushbuttonString;
end
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!