MATLAB Answers

Changing the xticks in a heatmap to a datetime ticks

5 views (last 30 days)
Gayan Lankeshwara on 21 Jun 2020
Commented: Ameer Hamza on 21 Jun 2020
I need to change the xticks of the following matrix to be in datetime format.
randMatrix = rand(5,10)
heatmap(randMatrix)
If I plot this, the xticklables are from 1 to 10.
But I need to change them as follows.
t1 = datetime(2020,06,21,8,0,0);
t2 = datetime(2020,06,21,17,0,0);
Time = t1:hours(1):t2 ;
So, I need to replace the xticks in the heatmap with the datetime ticks of Time ?
I tried this, but could not find what I want to do.

0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza on 21 Jun 2020
Try this
randMatrix = rand(5,10);
t1 = datetime(2020,06,21,8,0,0);
t2 = datetime(2020,06,21,17,0,0);
Time = t1:hours(1):t2 ;
h = heatmap(Time, 1:5, randMatrix);

4 Comments

Show 1 older comment
Ameer Hamza on 21 Jun 2020
I am glad to be of help!
Fego Etese on 21 Jun 2020
Hello Ameer Hamza, sorry to contact you like this, but its really an emergency, please I need your help with this question
I will be grateful if you can help me out, thanks
Ameer Hamza on 21 Jun 2020
Sorry! But I don't know how to solve that problem!

Sign in to comment.

R2019a

Community Treasure Hunt

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

Start Hunting!