MATLAB: How to add annotations to tab panels

annotation;tab panel

I found this code on the undocumented matlab blog. The slightly modified version is given below. However I am having trouble in adding annotations to the 2nd tab. I am unable to do that as of now.
hTabGroup = uitabgroup;
drawnow;
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1);
surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
b = axes('parent', tab2);
t=annotation('textbox');
set(t,'parent',gca);
surf(peaks);
tab3 = uitab(hTabGroup, 'title','Panel 3');
c = axes('parent', tab3);
surf(peaks);
I also tried to change the background colour to white using:
set(gcf,'color','w');
but this also does not seem to work. I am surely missing something but unable to figure out how to solve the problem. Any help would be appreciated. Thanks

Best Answer

hTabGroup = uitabgroup;
tab1 = uitab(hTabGroup, 'title','Panel 1');
a = axes('parent', tab1);
surf(peaks);
tab2 = uitab(hTabGroup, 'title','Panel 2');
b = axes('parent', tab2);
t = annotation(tab2, 'textbox'); % <== Container added as 1st input
% set(t,'parent', gca); % No, not the axes, but the tab
surf(peaks);
tab3 = uitab(hTabGroup, 'title','Panel 3');
c = axes('parent', tab3);
surf(peaks);
See doc annotation (container): The container can be a "figure object | uipanel object | uitab object", but not an axes.
The figure did change its color to white, but you could not see it, because it is completely covered by the uitabgroup.