How to pass a structure variable from callback to other callback .

조회 수: 1 (최근 30일)
Vinay kumar Reddy
Vinay kumar Reddy 2013년 2월 17일
Help Needed.
In a GUI M file I got a situation where I should pass a structure Variable form callback to callback.
Here is my code
function Run_Button_Callback(hObject, eventdata, handles)
for i=2:length(sc);
des=sc{i,2};
str=sc{i,3};
Requestor(1,i).UID=regexp(str, '(?<=Requestors UserID:).*(?=Requestors Email Address:)', 'match');
% extracting value and removing spaces....
Requestor(1,i).UID=strtrim(Requestor(1,i).UID{1,1});
end;
handles.Requestor.UID=Requestor.UID;
guidata(hObject, handles);
function Generate_Button_Callback(hObject, eventdata, handles)
Requestor.UID=handles.Requestor.UID;
Routed_Array=[ ];
for i=1:length(sc)
Sort_routed=strcmpi(Requestor(1,i).UID,Id(i).Manager);
Sort_routed=sum(Sort_routed);
switch Sort_routed
case 1
Routed_Array=[Routed_Array i];
end;
end;
I need help , I following got error
Reference to non-existent field 'UID'.
Error in ==> MailSend>Run_Button_Callback at 385 handles.Requestor.UID=Requestor.UID;
Please Help

답변 (2개)

Volkan Kandemir
Volkan Kandemir 2013년 2월 17일
you can use global variables easly to transfer data from one function to another one.
function main
myfun1
myfun2
function myfun1
global a
a.a=5;
a.b=10;
function myfun2
global a
a.a=a.a+a.b

Walter Roberson
Walter Roberson 2013년 2월 17일

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by