使用注释的带有一个动态超级标题的多个子图

Multiple subplots with one dynamic super title using annotation

我正在尝试为多个子图使用一个超级标题。我使用 annotation 来完成它。 annotation 在一个循环中。问题是 annotation 在非动态时工作正常但不幸的是,当我使用 Loop

时我需要更改标题

我使用了下面的代码,当标题没有变化时它可以正常工作。 (这只是随机数的一个例子)

clc;
clear;
a=rand(10,10);
for i=1:3
h(1)=subplot (2,2,1);
plot (a(:,1),a(:,2));
set(h(1),'Position',[.1 .35 .35 .5])
h(2)=subplot (2,2,2);
plot (a(:,1),a(:,2));
set(h(2),'Position',[.55 .35 .35 .5])
annotation('textbox', [0 0.85 1 0.1],'String',...
 'Test text Number=1','EdgeColor', 'none','HorizontalAlignment', 'center')

end

我尝试如下更改 annotation 行,但它不起作用

annotation('textbox', [0 0.85 1 0.1],'String',...
 'Test text Number=%d',i,'EdgeColor', 'none','HorizontalAlignment', 'center')

我不想在我的代码中使用外部函数,例如 (suptitle,suplabel..etc)

这会起作用:

temp=annotation('textbox', [0 0.85 1 0.1],'String',...
['Test text Number=',num2str(i)],'EdgeColor', 'none','HorizontalAlignment', 'center')