How can I use datetick with more than x, y, z in input and on Y-axis?

3 vues (au cours des 30 derniers jours)
Martinppp
Martinppp le 2 Fév 2018
Commenté : Martinppp le 2 Fév 2018
Hello,
I am using datenum to convert time txt in MM:SS.FFF in serial date number. The next step is to change those numbers in MM:SS.FFF with datetick when I am ploting.
My problem is that I have more than just 3 inputs (in datetick there is just 'x','y','z' in possibilities)to put in my plot and I would like to have the time Format in Y-axis.
I have :
Format = 'MM:SS.FFF';
x= datenum(txt,Format);
x1= datenum(txt2,Format);
x2= datenum(txt3,Format);
x3= datenum(txt4,Format);
x4= datenum(txt5,Format);
plot(y,x,y,x1,y,x2,y,x3,y,x4)
datetick('x',Format,'keepticks');
datetick('x1',Format,'keepticks');
datetick('x2',Format,'keepticks');
datetick('x3',Format,'keepticks');
datetick('x4',Format,'keepticks');
So I have 2 errors in this case: x1, x2, x3, x4 are not considering in input argument and x should be in X-axis.
How can I do it with datetick or with something else from my serial numbers from datenum ?
Thank you
Martin

Réponse acceptée

dpb
dpb le 2 Fév 2018
Syntax for datetick is
datetick(tickaxis)
not
datetick(wanteddateaxisvariablename)
Just need
datetick('y',Format,'keepticks')
However, I'd strongly suggest unless you're running a version of Matlab prior to R2014b to convert from datenum to the datetime class. plot and friends have subsequently been made datetime aware so don't need klunky datetick any longer.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by