Share data between functions in main

조회 수: 4 (최근 30일)
Nu9
Nu9 2011년 8월 30일
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

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 8월 30일
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
Fangjun Jiang
Fangjun Jiang 2011년 8월 30일
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 2011년 8월 30일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by