Why does surf bin datenum time in two bins?

1 view (last 30 days)
Lukas
Lukas on 17 Nov 2014
Commented: Lukas on 27 Nov 2014
Hi
I don't know whether I'm doing something wrong, or whether this is a bug. When I use
surf(t,Y,Z)
in which t is a timeseries given in the matlab continuous time datenum, surf only plots two bins in the t-dimension. My guess is this has something to do with the too small relative difference between the vector elements, so surf bins them together. But why does surf do this and how can I prevent this? I need datenum to then be able to use dateticks.
My current solutions is to substract floor(t) from t, so that my timeseries starts some hours after the 0 point of the datenum time. This is ok for now, because I only need the hours on the axis. But if I need more, it might not work.
  2 Comments
Star Strider
Star Strider on 17 Nov 2014
Posting the relevant parts of your code would help, especially your vector of dates and some actual or sample (t,Y,Z) data corresponding to them.
Also, how many dates/times do you want displayed?
Lukas
Lukas on 27 Nov 2014
Hi, thanks for answering (and sorry for me not reacting for such a long time, but for some reason I didn't get an e-mail notification even though I marked it to notify me)
When I do it now, I can't reproduce it exactly (I don't get two bins), but it still doesn't give me what I need (5 bins, still too).
I made the example code a bit easier to read, but it basically is the same as what I had. I want to plot a matrix with velocities V on the color axis. In one dimension it varies with time t, in the other with altitude h:
tdn = datenum(t);
[X,Y] = meshgrid(tdn,h);
sp = surf(X,Y,V','EdgeColor','none','LineStyle','none');
view(2);
caxis([-300 300]);
In this case it only gives me 5 bins in the time direction.
The time "vector" t is just 6 columns for YMDhms on every row. They're in this case all separated by 64 seconds (except the first 2). The altitude vector just has the altitudes (which are almost logarithmically spaced).
When I use
[X,Y] = meshgrid(tdn-floor(tdn),h);
instead I get what I want. Except then my time starts on the first day of the datenum timeline, so when I would use dateticks with not only the hms but also YMD I would get wrong dateticks.
If you think a look at the real data would help, I've attached a file 'variables.mat' which contains t, h and V.

Sign in to comment.

Answers (0)

Categories

Find more on Dates and Time 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!