set limits using xlim for strings

4 visualizaciones (últimos 30 días)
Aditya
Aditya el 2 de Feb. de 2014
Comentada: Image Analyst el 3 de Feb. de 2014
Hi, I wanted to know how to set string limits for a graph. I wanted to set axis limits as months of a year ('Jan' 'Feb 'Mar'). Also wanted to know whether I can pass an array or pass variable with predefined values in the xlim function. Thanks in advance.

Respuesta aceptada

Amit
Amit el 2 de Feb. de 2014
set(gca,'XTick',1:12,'XTickLabel',{'Jan','Feb','Mar','Apr' .... etc})
  2 comentarios
Aditya
Aditya el 3 de Feb. de 2014
Can we display variables instead of static strings? For eg. I want to display years like 2009,2010,... etc which should be dynamic
Image Analyst
Image Analyst el 3 de Feb. de 2014
Sure. You can make up a cell array with any string variables you want in it.
index = 1;
for y = 2009 : 2020
ca{index} = y; % or num2str(y) or sprintf('Year=%d', y) or whatever...
index = index + 1;
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by