How can I plot datetime as x-axis in pcolor ?
Show older comments
Hello Seniors,
I have time(datetime - 6047X1) need to be in x-axis, height(numeric value - 27X1) as y axis, C(27X6047) numeric values.
I am having error(Error using pcolor (line 65) Data inputs must be real.) while I want plot by using pcolor.
4 Comments
Shubham Gupta
on 14 Oct 2019
what's the datatype for 'time', 'height' & 'C' ? If anyone of them is complex, then I think that might not be allowed for 'pcolor'.
Jeevan Kumar Bodaballa
on 14 Oct 2019
Shubham Gupta
on 14 Oct 2019
One of the way can be:
dt = [datetime('yesterday'),datetime('today'),datetime('tomorrow')];
y = 1:3;
C = [3 4 5; 1 2 5; 5 5 5];
pcolor(datenum(dt),1:3,C)
a = gca;
a.XTick = datenum(dt);
a.XTickLabel = datestr(datenum(dt));
I am not sure if that's what you want but let me know if you have doubts.
Jeevan Kumar Bodaballa
on 15 Oct 2019
Accepted Answer
More Answers (0)
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!