how to title the plots using for loop?

5 次查看(过去 30 天)
Hi all,
I have a char array (attached) that i want to use it as a title in the for loop
any help would be appreciated.
Thanks a lot

采纳的回答

KSSV
KSSV 2018-12-5
load('DAYS.mat') ;
for i = 1:length(DAY)
figure(i)
title(DAY(i,:)) ;
end
  2 个评论
Lilya
Lilya 2018-12-6
Thank you Sir KSSV. it works but the figures are not showing one by one. it shows only the last one with all different dates.
Any help?
Thanks
Lilya
Lilya 2018-12-6
Here what i used
for i=92:140;
filename=[files(i).name];
% disp(['Processing ', files(i).name]);
sst = ncread(filename,'sea_surface_temperature');
lon = ncread(filename,'lon');
lat = ncread(filename,'lat');
sst = sst';
idxlon = find(lon>lonmin & lon<lonmax);
goodlon = lon(idxlon);
idxlat = find(lat>latmin & lat<latmax);
goodlat = lat(idxlat);
subset_sst = sst(idxlat,idxlon);
% mn=nanmean(nanmean((subset_sst)));
% TEMP=[TEMP,mn];
y=files(i).name(1:4);
dd=files(i).name(7:8);
mm=files(i).name(5:6);
DT=strcat(dd,'/',mm,'/',y);
DAY=[DAY;DT];
figure
hold on
orient portrait;
m_pcolor(goodlon,goodlat,subset_sst-273.15)
shading interp
colormap(jet);
m_proj('mercator','lon',[lonmin lonmax],'lat',[latmin latmax]);
m_usercoast('red_sea_f','patch',[0.8 0.8 0.8]); % gray color
m_grid('contour','on','tickdir','out','box','fancy','fontsize',10,...
'linewidth',1,'linestyle','--');
m_plot(Xlon,Xlat,'.','Color','k')
ylabel('Latitude','fontsize',14,'fontweight','bold');
xlabel('Longitude','fontsize',14,'fontweight','bold');
caxis([21 30]);
% title(DAY(i,:)) ;
colorbar;
hold off
pause
end

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by