how to title the plots using for loop?

조회 수: 9 (최근 30일)
Lilya
Lilya 2018년 12월 5일
댓글: Lilya 2018년 12월 6일
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개)

카테고리

Help CenterFile Exchange에서 White에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by