how to sum data every year

조회 수: 17 (최근 30일)
Hichem Younsi
Hichem Younsi 2020년 2월 3일
댓글: Adam Danz 2020년 2월 8일
hello
i have a 11322x6 double. i have the date in the first column, months and days in the third and the forth. on the fivth and the sixth colum i have the variables. temperature and degre days that i calculeted from temperature. now i need to sum every degre day of every year together , the problem years change the number evey 4 years so how to do it with a function or easy loop. i saw a lot of them on matlab but don't kenw how to use itnd i don't knew to apply it on my case

채택된 답변

Adam Danz
Adam Danz 2020년 2월 3일
편집: Adam Danz 2020년 2월 6일
No loop needed.
Use findgroups() on the appropriate column(s) to group the rows. Then use
to compute the mean of each group where data is the temperature column.
If your data contain missing values, you can use mu = splitapply(@(x), mean(data,'omitnan'), groups).
Let us know if you get stuck.
  댓글 수: 2
Hichem Younsi
Hichem Younsi 2020년 2월 5일
so i can't apply the findgroups in an array ?
Adam Danz
Adam Danz 2020년 2월 5일
편집: Adam Danz 2020년 2월 5일
Updated comment
You can't apply findgroups to a matrix but you can find unique rows of a table
or you can separate the columns of your matrix and use this syntax
Both of those links will show documentation that describes the syntax and provides examples.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Hichem Younsi
Hichem Younsi 2020년 2월 8일
oof that worked thank you Adam Danz. i convert the matrix to an table and then i used the findgroups to find how many days in each mounths in years and then i used the splitapply function to sum the variable on folwngs years. GREAT THANK YOU
Adam Danz

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by