different titles for animation
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nahid Atashi
el 23 de Jul. de 2019
Comentada: Nahid Atashi
el 23 de Jul. de 2019
Hi friends,
I have a code to make an animation which is fine and works but i need to creat title for each map
in this animation. I tried but couldn't make it as a loop.
Maps are monthly for 40 years from 1979:2018. the titles should be like: {'Jan 1979', 'Feb 1979',.................'Dec 1979', 'Jan 1980'.........}
and so on (12 month for each year).
could some body help me please?
thanks in advance
This is the main part of the code:
%% creat animat
for i=1:12
a=reshape(monthly(i,:),81,65);
a(~inMap)=nan;
for k=1:12
[c,h]=contourf(XX,YY,a ,'LineStyle','none');colorbar;
hold on
plot(lonos(:,1),latos(:,1),'black');
title (sprintf('% JAN 1979',k));
pause(1)
% input('-->','s');
end
end
0 comentarios
Respuesta aceptada
David K.
el 23 de Jul. de 2019
I would suggest creating the title like this:
months = {'Jan', 'Feb', ...};
years = num2str((1979:2018)');
for i = 1:40
for k = 1:12
title(strcat(months{k}," ",years(i,:)));
end
strcat is a string concatenation -> It puts the strings together. I assumed the outer loop is meant to be years so I changed it from 12 to 40 since you mentioned 40 years.
-Also note, it is highly recommended that you do not use i as a variable. It is the built in constant for the imaginary number.
Más respuestas (0)
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!