Effacer les filtres
Effacer les filtres

Repeating time values on x-axis

5 vues (au cours des 30 derniers jours)
Noush
Noush le 23 Nov 2021
Commenté : dpb le 30 Nov 2021
Hi there,
I have a table that contains a first column with time of the day and a second with the power of a machine. I would like to plot the power on the y-axis and the time on the x-axis for a week.
When I use the command plot(time,power) I get this:
The graphs overlap, as the times repeats itself for each day. I don't want that. I dont want to use the xtick method to solve this, as it would require me to specify each xticklabel right? That would take too long. Rather, I'd like the graph to produce the xticks automatically and plot in such a way that the graphs for each day are lined up after each other.
I also have a column with the dates, I just don't know how to put that all together in the correct way for it to plot it the way I want.
Can you help?
Thank you!
  14 commentaires
dpb
dpb le 30 Nov 2021
The other markedly different alternative would be to catenate the two variables as text and then scan them as a composite datetime...
dt=datetime(strcat(T(C:B,1),T(C:B,2)),'InputFormat','yyyyMMddhhmm');
which may well be the shortest, best way in the end.
NB: the above input format string will require the times all have double-digit hours, not single. The one-letter form of 'h' format string only works if the hour and minute fields are separated with the colon or other punctuation; it's simply too ambiguous a format without that indicator.
dpb
dpb le 30 Nov 2021
"... convert text to datetime ... then immediately call timeof day on that."
Ah! I don't recall having come across that suggestion before, Peter, but it's a good one. I didn't even think of timeofday ...

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by