MATLAB Answers

0

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

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.

1 Answer

Answer by Matt J
on 18 Oct 2019
Edited by Matt J
on 18 Oct 2019
 Accepted Answer

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

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?.
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...
I appreciate it, you really solved my whole past few days problem.

Sign in to comment.