Mean and SD for 3D matrix
Afficher commentaires plus anciens
Hello,
I have a 3D matrix (140 rows, 572 columns) for 91 cases which are safed in one .mat file. How can I create a new .mat file with the average Matrix and one for the SD Matrix? I have tried:
FileData = load('Matrix.mat');
Matrix_Avg = mean(3, Parameter);
But always get an error.
Help is much appreciated!
2 commentaires
Rik
le 17 Fév 2021
From your other question I suspect you don't have a 3D array, but a struct array. Is that correct? Please attach your data or post code that creates similar data.
Réponses (1)
The cat function is one of the few (if not the only) functions where the dimension input comes first. In most other functions (including both mean and std) it comes after the data.
A = randi(16, 4, 4);
B = magic(4);
C = cat(3, A, B) % Concatenate in dimension 3
D = mean(C, 3) % Take the mean along dimension 3
6 commentaires
doehr001
le 17 Fév 2021
Rik
le 17 Fév 2021
Did you read what Steven wrote? The syntax for the mean function is not what you wrote, it should be mean(data,dim).
doehr001
le 17 Fév 2021
Steven Lord
le 17 Fév 2021
What is the full and exact text (everything displayed in red and/or orange) of the error/warning messages you received when you ran the following code?
Avg = mean(Matrix, 3);
doehr001
le 17 Fév 2021
Rik
le 18 Fév 2021
When posting an error message, please make sure to post all the red text. And please use the layout tools to format your code as code.
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!