standard deviation and mean across specific columns of a 3D matrix

1 visualización (últimos 30 días)
I have multiple excel files that I need to analyze. The data is voltage vs time, and the size of each file is 700x216 double. Each file has multiple tests and multiple trials for each test. I need to average the trials for each test across rows. Then I need to compare the averaged data between tests(files). I can import all the files I need with a for loop, construct a 3D matrix, and get the mean of all values across tests. Is there a way to average across specific rows for all tests and run statistics such as standard deviation across the averaged data in a 3D matrix? Is a 3D matrix the best approach for this?
% 3D matrix
mtx = cat(3,(data{:,1}));
%mean of matrix
Mmtx = mean(mtx,3);
% tried this but only gave me the average of the first data set
MmtxT1 = mean(mtx(:,[2 3 4 5]),2);
  2 comentarios
dpb
dpb el 7 de Ag. de 2020
" Is a 3D matrix the best approach...?"
Possibly not...it would help to know the layout of the 2D files and over what parts are to be averaged. That you have multiple tests and trials combined in the one file means need to be able to reference them -- another structure built around that arrangement could possibly work more effectively.
Michael Grybko
Michael Grybko el 10 de Ag. de 2020
Editada: Michael Grybko el 10 de Ag. de 2020
Thank you for the input!
Below is a small sample of the data from one excel file I'm working with. The complete excel files have 702 rows and 216 columns. The first column is time then the remaining are test points. I want to average all of the columns in test 1 across all rows. For example the first row of data shown ( (-4910.53 + 26015.6 + -9772.91 + 7301.15)/4) = 4.6583e+03. Then I will have to do this for Test2, Test3……Testn. This will have to be done for 12 files. Then I will need to average the averaged results for each test across all files and be able to run some stats such as standard deviation.
Step 1 Test1 Test 2
Time (ms) Trial (nV) Trial (nV) Trial (nV) Trial (nV) Trial(nV) Trial (nV) Trial (nV) Trial (nV)
-50 -4910.53 26015.6 -9772.91 7301.15 1084.97 23010.38 11433.85 -15257.8
-49.5 -3342.13 25431.91 -10740.3 13557.5 1612.12 24849.7 11276.54 -15358.4
-49 -2074.94 25478.31 -11460.9 18033.31 2235.14 26552.7 10679.87 -14595.7
-48.5 -359.066 25694.99 -10922.9 22426.1 2468.09 26921.42 9826.5 -13412.2

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 7 de Ag. de 2020
Editada: Matt J el 7 de Ag. de 2020
If the idea is to average along rows 2 through 5 in every slice, you would want this,
MmtxT1 = mean( mtx([2 3 4 5],:,:) , 2);
Then, you can take the standard deviation across slices with,
std( MmtxT1 ,[],3)
  2 comentarios
Michael Grybko
Michael Grybko el 10 de Ag. de 2020
Thank you Matt J!
What I want to do is average across rows of four columns resulting in one column of means with an equal number of rows as the original data. Your suggestion was helpful. I was not including the 3rd dimension. This is what I want to do:
MmtxT1 = mean(mtx(:,[2 3 4 5],:),2);
Matt J
Matt J el 10 de Ag. de 2020
OK, but if you have achieved your objective, please Accept-click the answer.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by