time series and grouping

2 visualizaciones (últimos 30 días)
akk
akk el 19 de Oct. de 2020
Respondida: Eric Sofen el 12 de Nov. de 2020
Hello,
I have a table with multiple sites (SITE_ID) and temperature time series associated with each site. Each site has a lat, lon and depth as well. I would like to group the data by SITE_ID, and then plot the tempearature time series associated with each site. TIMESTAMP is a string and TEMP_C is a double.
I know the first step is to group:
[G,ID]=findgroups(SITE_ID)
but am not sure how to plot associated time series for each unique site
Thank you!

Respuestas (1)

Eric Sofen
Eric Sofen el 12 de Nov. de 2020
It's tough to give a detailed answer without seeing the structure of your data and preliminary code, but here are a few suggestions:
1) Convert your TIMESTAMPs to datetime.
2) You could use varfun to plot, using SITE_ID as a grouping variable. Something like
p = varfun(@(dt,temp) plot(dt,temp), t, 'InputVariables',{'TIMESTAMP','TEMP_C'},'GroupingVariables','SITE_ID')
It will actually return a table with the line objects for the charts. If you use hold on, you can get all the plots on one chart.
3) If you want subplots, you're right that you're probably better off iterating over the unique values of SITE_ID.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by