MATLAB: Change y values in figure to names

figureMATLABplot

I was able to plot temperatures of each hour in the year and got this result using this command:
plot(A(1:8760,5)')
X axis is the hours of the year
Y axis is the temperature vaule of each day
Question:
How can I change the crosses values in X axis to be the months names rather than hours?
i.e.
January instead of 1000
Febraruy instead of 2000
and so on

Best Answer

You need to calculate where each month falls, in terms of hours:
ttk = datetime(2019,1:13,1);
set(gca, 'xtick', hours(ttk-datetime(2019,1,1)), 'xticklabel', cellstr(datestr(ttk,'mmm')))
Check the specific year of your data; the alignment will be different in leap years vs non-leap years.
Alternatively, if you actually specify datetime values for your x-values, Matlab will create a date axis that automatically labels things appropriately:
t = datetime(2019,1,1) + hours(1:8760);
plot(t, A(1:8760,5)');