Loop through tables in a cell array
Show older comments
I have two 41x1 cell arrays 'DS_10B' and 'DS_10T' containing 41 different tables each. The tables contain stock return data from column 4 onwards. (find the data attached)
First I want to loop through all tables of the array 'DS_10B' and calculate the mean stock return. I don't care about the mean return per table or column but only need the overall mean return of all the combined data in the array.
Then I want to repeat the exact same procedure for the other array 'DS_10T'.
I already managed to calculate the mean of one single table's stock return data with this:
% Extract test table
t = DS_10B{1,1};
% Extract relevant columns of test table
% Get all columns with stock return data of table as a column vectors of doubles
lastColumns = t{:,4:end};
% Reshape into one single column in order to calculate mean
lastCo = reshape(lastColumns,[],1);
% Mean the last column but use omitnan
mean_table = mean(lastCo,'omitnan');
Would be delighted if someone could help me with the for loop.
Thanks a lot in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!