Hello again fellow members, well after playing for an hour. I finally figured it out, but instead of deleting the question. I thought why not just post an answer. So here is my solution.
txt = uieditfield(fig,...
'Position',[100 175 100 22],...
'tag','texteditField',...
'ValueChangedFcn',@(txt,event) textChanged(txt,lbl));
end
% Code the callback function.
function textChanged(txt,lbl)
lbl.Text = txt.Value;
end
In the above code, if I want to find this graphical object from any other funtion then I can use findobj with the current figure as a first argument of findobj.
Txt = findobj(figure,'tag','texteditField')
TxtCallback = Txt.ValueChangedFcn;
TxtCallback(Txt);
Thank you