I have an array of calendarDuration data, formatted as (for example) 18y 5mo 21d.
The data is the ages of participants when I tested them. I subtracted their birth date from the testing date, using caldiff.
I'd like to calculate the mean age of my participants. The obvious step would be to do something like:
Where ages is a calendarDuration array (e.g. a 1 x 33 calendarDuration array with the data I'm using).
When I try this, I get the error
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
What am I missing? For example, is there some different mean function I'm supposed to use for calendarDuration arrays? I couldn't find anything about this when I searched. The nearest I found was a description of timeseries means:
These use the built-in matlab 'mean' function. Which is about what I'd expect - adapting the built-in function so that it detects homogenous data type and operates accordingly would seem so useful that it would have been added long ago. But perhaps not for calendarDuration data, as per my example?
P.S. If anyone can tell me how to get the mean of calendarDuration data, could you tell me how to get standard deviation as well?