MATLAB Answers

Calculating statistical functions for a structure array which each cell has a different size

1 view (last 30 days)
Hi,
I have a structure array which is mentioned below.
59x1 double 38x1 double 39x1 double 25x1 double 16x1 double
Each cell in my array includes some data and the number of data for each cell varies from one to another. Indeed, I have provided a small piece of my array here. The original one has 1600 cells and each cell contains about 40-80 data.
I know how to calculate the Mean, Variance, Skewness, Kurtosis, Max, Min, Median and quantile (10-90) when I'm working with a matrix but I cannot do the same task for a structure array. I really need to calculate the mentioned mathematical functions for my array.
Please let me know what should I do.
I have been struggling with this issue for a week and still don't know what should I do.

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 18 Oct 2019
Edited: Matt J on 18 Oct 2019
A structure array doesn't have "cells" and doesn't look like that. I assume you really mean your data is a cell array, in which case, you can use cellfun, e.g.,
mean_of_cells = cellfun(@mean, myData)

  3 Comments

Farbod Tavakkoli Khomeini
Farbod Tavakkoli Khomeini on 18 Oct 2019
Thank you for your help,
Actually, I want calculate the Mean of the whole array but this function is just giving the mean of each cell. Also, I cannot use this funtion for Min, Max, and Quantile. Do you have any more suggestion for that?.
Matt J
Matt J on 18 Oct 2019
Also, I cannot use this funtion for Min, Max, and Quantile.
Why not?
Actually, I want calculate the Mean of the whole array
Just concatenate all your cells into one array
array=vertcat(myData{:});
mean(array)
max(array)
etc...

Sign in to comment.

More Answers (0)


Translated by