How can I change the title of the subplots with forloop iteration?
Show older comments
I have 24 subplots as shown below. I want to give the title name (CB1000(m)) to the first 6 subplots in a row and then the next title name (CB2000(m)) to the next 6 subplots and so on. What actually I want is to change these title names according to the loop iteration "h=1000:1000:4000" but having the same title for the 6 subplots in a row. I'm using the syntax
title(sprintf('CB %d(m)',h))
but it's not suitable to use. How can I solve this problem? A part of my program is given below

%% draw all of the tables
figure
count = 1;
for h = 1000:1000:4000
for fov = [0.2, 0.5, 1, 2, 5, 10]
a = 0.01:0.01:0.05;
r = 4:20;
[X, Y, Z] = meshgrid(r, a, h);
subplot(6, 4, count)
Norm_costf=costf./max(costf)
imagesc(r,a,Norm_costf,'Interpolation', 'bilinear');
% title(sprintf('CB %d(m)',h))
shading interp
hold on
c_levels = (0:0.1:1);
[c,h] = contour(r,a,Norm_costf,c_levels,'k');
clabel(c,h,'fontsize',7)
hCB=colorbar
hCB.Label.String='Normalised Cost function';
gm=costf==min(costf(:));
hold on
scatter3(X(gm),Y(gm),Z(gm),'w*')
hold off
xlabel('CER_{ref}(\mum)')
ylabel('\alpha_{ref}(1/m)')
set(gca,'xlim',[4 20],'xtick',[4 12 20],'ylim',[0.005 0.055],'ytick',[0.005 0.025 0.055]);
xlim([4, 20])
count = count + 1;
hold on
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


