plotyy: Does matlab recognize gaps in date time line when plotting dates on y-axis?

2 次查看(过去 30 天)
Hey everyone,
I have a simple question that I cannot seem to find the answer to:
When I have a vector that is made up of chronological dates (with a few dates missing) and I use this vector in plotyy to plot something - does matlab recognize that there are a few dates missing and therefore plots a hole in the plot? For example I have sales data for each day of eleven month of the year, july is missing. When I plot the data with plotyy and use my date vector that comprises all daily dates except for the july dates - will I be able to see the gap in my plot? Or does matlab simply eliminate the month july since it cannot find information about july in the data vector or the date vector? So I won't be able to see the gap graphically?
I hope my question is clear... I had some problems formulating it in English...
Thanks a lot!!

回答(2 个)

Roger Wohlwend
Roger Wohlwend 2014-10-17
Matlab plots the data you provide. Matlab does not check for missing data or something on its own. However, it is actually quite simple to detect the kind of missing data your talking of. Just do the following:
d = diff(TimeVector)
If you have daily data, then most elements in the vector d are equal to 1 or 3. If there is a whole month missing, then one element is the vector is 30 or something like that. So all you have to do is check the vector d for outliers. These outliers tell you that there is missing data.

Star Strider
Star Strider 2014-10-17
编辑:Star Strider 2014-10-17
If you want to create a gap for July, plot the two series separately:
ds = datenum([2014 01 01; 2014 06 30; 2014 08 01; 2014 12 31]); % Create Data
dv = {ds(1):7:ds(2); ds(3):7:ds(4)};
sv = {sin(2*pi*dv{1}/75); sin(2*pi*dv{2}/75)};
figure(1)
plot(dv{1}, sv{1}) % Plot Jan-Jun
hold on
plot(dv{2}, sv{2}) % Plot Aug-Dec
hold off
grid
datetick('x', 'mm/dd')
produces:

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by