standard deviation and mean across specific columns of a 3D matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Michael Grybko
el 7 de Ag. de 2020
Comentada: Matt J
el 10 de Ag. de 2020
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
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.
Respuesta aceptada
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
Matt J
el 10 de Ag. de 2020
OK, but if you have achieved your objective, please Accept-click the answer.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!