Mean and SD for 3D matrix
2 views (last 30 days)
Show older comments
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 Comments
Rik
on 17 Feb 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.
Answers (1)
Steven Lord
on 17 Feb 2021
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 Comments
Rik
on 18 Feb 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.
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!