Filter löschen
Filter löschen

Plot 3d figure (surface) with one time-dimension axis

2 Ansichten (letzte 30 Tage)
Vasek
Vasek am 3 Apr. 2012
Hello,
I'm trying to plot: surf(d,t,v)
where:
d is a vector - consists of integer values, e.g. d=[10 11 12 .... 46]
v is an input matrix - consists of integer values, in dimension d x t
t is a vector - consists of one-minute time steps over the defined period, e.g. t= [14:33 14:34 14:35 .... 18:21]
So far, I've been able to plot the surface using some "dummy" values for y-axis (t=[1 2 3...120]). Does anybody know how to plot such surface and having the y-axis in hh:mm format? The problem is that when I'm using the dummy values, the graph contains no relevant information about time (y-axis is scaled in the integer values)

Antworten (2)

Thomas
Thomas am 3 Apr. 2012
For y axis having time in HH:MM format, first convert the time you have to datenum
doc datenum
Then plot the graph using the datenum value on y and to show it in the HH:MM format on the graph use datetick
doc datetick
  3 Kommentare
Thomas
Thomas am 3 Apr. 2012
tm = {'16:34';'16:35';'16:36';'16:37';'16:38';'16:39';'16:40';'16:41';'16:42';'16:43'};
datenum(tm,'HH:MM')
Vasek
Vasek am 3 Apr. 2012
Well, your code proceeded without any bug, however then it has "squeezed" the surface into a single line.
My plot looks like this:
%%
tm = {'16:34';'16:35';'16:36';'16:37';'16:38';'16:39';'16:40';'16:41';'16:42';'16:43'};
t = datenum(tm,'HH:MM');
s1 = surf(t,d,velocity);
datetick('x','hhmm')
shading interp;
colormap jet;
freezeColors
hold on;
m1 = surf(t,d,control);
datetick('x','hhmm')
alpha (m1, 0.4);
colormap winter;
As you can see, I'm plotting two surfaces into the one image and both of them were actually reduced into the line (in extent of the x-axis)

Melden Sie sich an, um zu kommentieren.


Vasek
Vasek am 3 Apr. 2012
I used an alternative way with re-labeling the axis: set(gca,'XTickLabel'['16:34';'16:35';'16:36';'16:37';'16:38';'16:39';'16:40';'16:41';'16:42';'16:43';'16:44'])
But it's quite annoying. First I have to prepare "dummy" values and then I have to define these labels following syntax 'label1';'label2';....
It's not really smooth way :D

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by