MATLAB: How to calculate mean on data from cell array of 3D struct array

cell array struct array struct mean

I have cell array Data_output (dimensions 1×10), which contains 10 three-dimensional structures (dimension 7x6x2). Each element of this 7x6x2 structure array is a structure and the structure is same for all elements. I want to calculate mean value across columns of part of the structure Data_output{1}(:,6,1).dom_freq_PRSA_down where dom_freq_PRSA_down is in each structure matrix of freque
if true
mean(Data_output{1}(:,6,1).dom_freq_PRSA_down,1) % do not work, error
P1V6T10_allFiles = Data_output{1}(:,6,1).dom_freq_PRSA_down % does not retrieve all data
mean(P1V6T10_allFiles,1) % give not desired results, due to fact that it does not contain all data
endncies.
Firstly, i could not calculate mean(Data_output{1}(:,6,1).dom_freq_PRSA_down,1), i got error to many input arguments. Secondly, when i print Data_output{1}(:,6,1).dom_freq_PRSA_down it has much more rows than when i print P1V6T10_allFiles where P1V6T10_allFiles = Data_output{1}(:,6,1).dom_freq_PRSA_down. I can calculate mean(P1V6T10_allFiles,1) and it does not average across all values from Data_output{1}(:,6,1).dom_freq_PRSA_down so that is not what i need. Also, do you know how one can see what is the type of Data_output{1}(:,6,1).dom_freq_PRSA_down, is it a array, struct array, or something other
Thank you.
Do you have any suggestions what should i try?

Best Answer

cat(3,Data_output{1}(:,6,1).dom_freq_PRSA_down)
take the mean as appropriate, e.g.:
mean(...,2)
"do you know how one can see what is the type of Data_output{1}(:,6,1).dom_freq_PRSA_down, is it a array, struct array, or something other"
It is none of those because what you have defined is actually a comma-separated list, which is a list of separate individual variables. That is why you got the "too many arguments" error, because you provided mean with multiple separate inputs: this is not something that it appreciates. However you can easily concatenate those separate variables into one, as my answer shows. You can learn more about comma separated lists here: