# Three dimensional averages?

4 vues (au cours des 30 derniers jours)
Lee le 14 Fév 2022
Commenté : Lee le 14 Fév 2022
I have a data set that is 18x8x3, 18 mice completing a maze 3 times over 8 days. I need to calculate the average time for each mouse averaged over all 8 days and 3 trials on each of the 8 days. I'm kind of lost on how to do it. I started off with:
mouseavg= mean(mouse(1:18,:,:)); %where the data set is named 'mouse'
This code returned a 1x8x3 and i'm pretty sure it's not what i'm looking for, and I couldn't even really tell you what it is giving me. This is my first time working with three dimensions and I'm really struggling to wrap my brain around it.
As a bonus I need to print the fastest and slowest time and which mouse it came from. Any and all help appreciated. Thanks!
edit to ask: should I use some kind of for loop?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

AndresVar le 14 Fév 2022
Modifié(e) : AndresVar le 14 Fév 2022
You can specify the dimension of averaging: Average or mean value of array - MATLAB mean (mathworks.com)
Then you can try
mouseavg = mean(mouse,[daysDim trialsDim])
Or you can reshape it so that all trials appear as columns: Reshape array - MATLAB reshape (mathworks.com)
mouse2=reshape(mouse,numberOfMice,[])
mouseavg = mean(mouse2,2);
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Lee le 14 Fév 2022
Thank you! The mouseavg=mean(mouse,[daysDim trialsDim]) worked perfect!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by