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

조회 수: 5 (최근 30일)
Vasek
Vasek 2012년 4월 3일
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)

답변 (2개)

Thomas
Thomas 2012년 4월 3일
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
Thomas
Thomas 2012년 4월 3일
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 2012년 4월 3일
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)

댓글을 달려면 로그인하십시오.


Vasek
Vasek 2012년 4월 3일
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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by