How to find the mean of categorical data

12 views (last 30 days)
Isabelle Lowson
Isabelle Lowson on 11 Feb 2020
Answered: Sindar on 12 Feb 2020
How can I find the mean distance travelled on each day of the week over a certain period of time. I have the distance travelled for each day but need to find the mean for each week day.

Answers (1)

Sindar
Sindar on 12 Feb 2020
check out splitapply. You may need to change the format of your data, but it does exactly what you want:
G = findgroups(Day);
mean_dist = splitapply(@mean,distance,G);

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!