Weird lingering data in MatLab plot?

50 views Asked by At

I have the following code (it is reproducible):

clear figure
nSites = 3;

ha = tight_subplot(nSites,1,[.01 .01],[.1 .1],[.1 .1]);
display(ha);
for ii = 1:nSites; 
    axes(ha(ii));
    yData=randn(365,1); 
    plot(yData);
    if ii~=nSites
        set(ha,'XTickLabel','');
    else
        set(ha,'XTickLabel','');
        NumTicks=6;
        L = get(gca,'XLim');
        set(gca,'XTick',linspace(L(1),L(2),NumTicks));
        datetick('x','mm/dd','keepticks');  
    end 
end

As you can see from the line that says yData=randn(365,1);, there are 365 data points (one year).

However, when you run this, you'll notice that it plots from 1/1 to 2/3, which is more than one year (400 values).

Why is this?? Is there a default value I'm not aware of? There are no NaN values, so this is a mystery to me....

Any help is appreciated!!

0

There are 0 answers