Borrar filtros
Borrar filtros

Problem with sum in cell

2 visualizaciones (últimos 30 días)
lena kappa
lena kappa el 7 de Abr. de 2022
Comentada: Voss el 7 de Abr. de 2022
Hi everyone i have a 5x2000x5 cell and i want to take the mean over it in the following way:
when i take yf= (y{1,1000,1}+y{2,1000,1}+y{3,1000,1}+y{4,1000,1}+y{5,1000,1})/5 for example i get what i want which is the mean over the first index y{i,1000,1} while keeping the second and third index constant.
But when i try to do this with the next command y=(y{mean(n),1000,1}) or even y = (y{sum(n),1000,1})/5 I get a different result.
Does anyone know how can i do this correctly without having to type manually all the values?
(The sizes in the cells are 1x99 double).
  2 comentarios
Stephen23
Stephen23 el 7 de Abr. de 2022
@lena kappa: what are the sizes of the data in each cell?
lena kappa
lena kappa el 7 de Abr. de 2022
Hi @Stephen it's 1x99 double.

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 7 de Abr. de 2022
y = repmat({randn(1,99)},5,2000,5); % making a cell array like yours
yf = mean(vertcat(y{:,1000,1}),1) % performing the mean like you want to do
yf = 1×99
0.1551 0.3661 -1.9613 0.2915 -2.2489 -1.3732 -1.3199 -0.4444 -0.1476 0.6717 -0.7227 0.4332 0.6203 -1.3426 1.8906 0.5887 -0.6570 0.3509 -0.4744 -0.2150 0.9625 -0.9948 0.8026 1.3543 0.9013 1.2162 -0.7348 -1.0374 -0.4461 -0.5068
  2 comentarios
lena kappa
lena kappa el 7 de Abr. de 2022
Thank you very much!
Voss
Voss el 7 de Abr. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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!

Translated by