I am working in MATLAB with a structure containing numeric arrays of different sizes, with rows like these:
SCD | HTD | EHD | CSD
T = [ 300*256 | 300*62 | 305*80 | 305*256 ...
200*256 | 400*62 | 105*80 | 505*256 ...]
and T contains many rows (size(T) = [1,965]). What I would like to do, is for each column, to compute the mean of the component over rows. I currently do it like this:
Tmean = [] ;
for i = 1 : size(T,2)
A = T(i).SCD ;
Tmean(i).SCD = mean(table2array(A));
end
And we need to do this over all columns. Is it possible to do this without using many loops?
The output of T(1) and T(2) look like this:
T(1)
ans =
SCD: [305x256 table]
HTD: [305x62 table]
EHD: [305x80 table]
DCD: [337x51 table]
CSD: [305x256 table]
CLD: [305x120 table]
movieId: 89
T(2)
ans =
SCD: [263x256 table]
HTD: [263x62 table]
EHD: [263x80 table]
DCD: [732x9 table]
CSD: [263x256 table]
CLD: [263x120 table]
movieId: 93
I expect Tmean_SCD for T(1) to look like a [1*256] array and the same for T(2) and all. Because all columns in the first field have 256 columns we can place them in an array with 256 columns and 965 rows.
T(i).SCDcontains an array of values you want averaged? For each i a new array? And then do this for all columns in the struct?T(1)andT(2)..Tmeanto look like (again show the expectedTmean(1)andTmean(2))..