Share data between functions in main

1 visualizzazione (ultimi 30 giorni)
Nu9
Nu9 il 30 Ago 2011
hi,i've a project that open a sub-gui to input some values and it sendds to main-gui. in main gui i need to use those values in a function that plot the result of simulation. i'm not using guide.the code:
function [] = gui_passdata()
S.fh = figure('units','pixels',...
'position',[20 104 851 596],...
'numbertitle','off',...
'name','Simulação',...
'resize','on');
S.ed = uicontrol('style','text',...
'units','pix',...
'position',[50 414 101 31],...
'string','Temperatura.');
S.pb2 = uicontrol('style','pushbutton',...
'units','pix',...
'position',[549 30 151 31],...
'string','Executar',...
'callback',{@pb2_call,S});
guidata(S.fh,S);
uicontrol(S.ed)
function [] = pb2_call(varargin)
% Callback for GUI_24 pushbutton.
S = guidata(gcbf); % Get the structure.
i want to pass data from gui_passdata to pb2_call but i only find how to share data with GUI

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 30 Ago 2011
Well, since you are not using GUI, I think it's easier. You can define the output argument of your function gui_passdata() and pb2_call().
  3 Commenti
Fangjun Jiang
Fangjun Jiang il 30 Ago 2011
All I am saying is that you are not bounded by the GUI template. You can return any data in any format you like in your function. Maybe give it a good thought first and plan a good data structure.
Nu9
Nu9 il 30 Ago 2011
ok your're right, but i've doubts about the return data from a structure. i can define in pb2_call this:
temp=s.ed
,after i get the structure?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by