Domanda

When facing data in the time domain i seem to run into problems setting the exact limits on the x-axis with matlab.

Thus i plot my data and give the xlim in matlab time and set the limits:

minTT = datenum(2008,10,31,17,12,00);
maxTT = datenum(2008,10,31,17,19,00);
xlim = ([minTT maxTT]);

Then i use the date tick option to convert the matlab timing to "real clock time".

datetick('x',13,'keepticks');

The 'keep ticks' option is still better than none and i tried with both. But what i get out is a plot that is going from: 17:12:28 to 17:17:58.

I have tried editing the ticks on my own as suggested from another post at StackOverflow like this:

ticks = get(gca, 'xtick') 
newTicks = linspace(ticks(1), ticks(end), 8);
set(gca,'Xtick', newTicks)

but even that doesn't work out and gives me limits from 17:12:28 to 17:17:31.

Is there any way to really force matlab to use specific times on the axis whether or not the data doesn't exactly start there?

È stato utile?

Soluzione

You can use the 'keeplimits' flag to datetick() - it does just what it says, much like 'keepticks'

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top