Date axis in matlab heatplot

Here is my scirpt to make temp of different date.
%%"date" is a matix which show values of date. For that I have converted the dates into number in excel and using those numbers to plot
%% 'b' show the different locations for those I am plotting the airtemp.
%% "temp" is a matrix having the temperature of different location at different dates.
heatmap(date,b,temp);
annotation('textarrow',[1,1],[0.5,0.5],'string','T(°C)','FontSize',16,...
'HeadStyle','none','LineStyle','none','HorizontalAlignment','center',...
'FontName','Times New Roman','FontWeight','bold','TextRotation',90);
colormap(flipud(pink));
title({('T')});
names_1= {'Point 1','Point 2','Point 3','Point 4','Point 5','Point 6','Point 7'};
ax = gca;
ax.YData=names_1;
ax.XLabel='Date';
ax.FontSize = 16;
ax.FontName='Times New Roman';
Now I want to convert x-tick into date. Please tell me how I can do that?

 Risposta accettata

dpb
dpb il 14 Feb 2021
" I have converted the dates into number in excel and using those numbers to plot"
Don't do that!!!
Read the dates as datetime in to begin with -- then heatmap will automagically use a date axis.
I'd suggest using
detectImportOptions
readTable
will lead you to easier solution path.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by