plot each cast for each year using findgroups and splitapply

5 ビュー (過去 30 日間)
akk
akk 2020 年 10 月 16 日
コメント済み: Ameer Hamza 2020 年 10 月 20 日
Hello,
I have a dataset with temperature, depth, castID and year. For each year, there are multiple casts, and the castID is associated with multiple temperature and depth readings. I would like to group the data by year, then plot each individual cast in that year using a specific color so that each cast associated with e.g., yr 2010 is green.
group_yr=findgroups(CASTYEAR);
figure;hold on;
Y=splitapply(@plot,TEMP_DEGC,DEPTH_M,group);
The issue is that matlab assumes all the casts in 2010 is a continuous dataset and so the plot lines are continuous as well, rather than seperate for each castID. I think I should also apply: group_ID=findgroups(CASTID);
But Im not sure how to plot according to group_ID and group_yr, and when I use:
Y=splitapply(@plot,TEMP_DEGC,DEPTH_M,group_ID(group_yr==1);
it does not work.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 17 日
You can use multiple variables to create groups using findgroups()
groups = findgroups(CASTYEAR, CASTID);
  2 件のコメント
akk
akk 2020 年 10 月 19 日
Thank you. If I did:
[G,ID]=findgroups(CASTYEAR,CASTID)
how would I then plot the temp,depth associated with each group?
Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日
You can still use the line
Y=splitapply(@plot,TEMP_DEGC,DEPTH_M,group);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by