how to title the plots using for loop?

5 visualizzazioni (ultimi 30 giorni)
Lilya
Lilya il 5 Dic 2018
Commentato: Lilya il 6 Dic 2018
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

Risposta accettata

KSSV
KSSV il 5 Dic 2018
load('DAYS.mat') ;
for i = 1:length(DAY)
figure(i)
title(DAY(i,:)) ;
end
  2 Commenti
Lilya
Lilya il 6 Dic 2018
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 il 6 Dic 2018
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by