Loop through tables in a cell array
이전 댓글 표시
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!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!