简体   繁体   中英

Averaging different sized (3D)matrices

I have three matrices with dimensions C11a=(1000x12x10), C11k=(1000x12x10), and C1c(1000x12x9). For description lets say they represent (datapoints x exercises x trials). I am trying to find the mean output for each exercise over all three tests but am having trouble due to the different sized matrices. Any help is appreciated! Thanks

What I have so far:

1L= mean(C11a);
2L= mean(C11k);
3L= mean(C11c);
left= (3,1L,3L,4L);
Out=mean(left,3)

If your objective is to obtain the average of all exercises (vector of size 12) you can cocatenate your three matrices into a big matrix of size 100x12x29

big_matrix=cat(3,C11a,C11k,C1c)

And then when you run the mean command, you can specify over which dimension to run (default is 1), so you have to run it twice, once over the first dimension, then over the third dimension. You can do it at once like this:

out=mean(mean(big_matrix),3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM