plot graph with dates for different years
Mostra commenti meno recenti
Hi everyone,
For my work, I am asked to plot graphs production for every year.
I have a daily production for every year since 2012. I am trying to find a way to compare the production of every year for the same dates.
I also have another difficulty : if I have a 0 for some days, it must not be represented on the graph (and they don't always show at the same period...)
Thanks in advance
Risposte (1)
dpb
il 23 Set 2017
Create a datetime vector for the data and then select by month and day with logical addressing to build the datasets for each unique month/day combination of a year (how many you have will depend upon whether the facility operates on only 5-day, 6-day or 7--day weeks). You may want to treat Feb 29 as a special case as there's only one of those every four years plus whether it is on a workday besides so there may not be much data for it.
As for the second question, that one's easy -- Matlab graphics ignores NaN in the dataset and so you simply substitute NaN for zero which is also ducksoup--if the data are x, then
x(x==0)=nan;
does it for you.
If you haven't, I strongly recommend opening the online doc and starting at the "Getting Started" section and work thru the tutorial info on the basics of Matlab syntax and data handling. When you get a feel for those basics and can do the examples therein, then you'll be ready to go read on the Data Types and concentrate on time-handling in Matlab. Use the newer datetime rather than the venerable datenum; you can get the end result with either but the newer class has some nice features the old doesn't, particularly when it comes to time-axis plotting.
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!