I have generated a cell array of 1x5 cells with a 10x1 column vector on each cell.
How can I find the average of all the column vectors? So to have a final 10x1 new column vector that contains the means. Thank you
I would concatenate the cell array contents along the second dimension (using cat
and {:}
indexing to get a comma separated list) and then take the mean along this first dimension
result = mean(cat(2, data{:}));
Since your data is purely numeric, you should avoid cell arrays and instead deal with a 5 x 10
matrix as that will be much more performant. You can easily create that the same way we did above.
matrix_data = cat(2, data{:});