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!

답변 (1개)

Eric Sofen
Eric Sofen 2020년 11월 12일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

akk
2020년 10월 19일

답변:

2020년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by