the problem with mean function

3 visualizaciones (últimos 30 días)
Rica
Rica el 8 de Nov. de 2012
i use this function to build the mean of vector:
% mean_phase=mean(reshape(phase(:),25,[]))
i get this error with the size of the vector:
*Product of known dimensions, 25, not divisible into total number of elements*
How could i solve this Problem ?

Respuesta aceptada

Pedro Villena
Pedro Villena el 8 de Nov. de 2012
Editada: Pedro Villena el 8 de Nov. de 2012
mean_phase=mean(reshape(phase(1:25*floor(numel(phase)/25)),25,[]))

Más respuestas (1)

Rica
Rica el 8 de Nov. de 2012
thanks. But my task is to have a mean value each 25 Value. I thought abaout adding some zeros at the end of the array to get the appropriate length. I do not how.
  1 comentario
Andrei Bobrov
Andrei Bobrov el 8 de Nov. de 2012
Editada: Andrei Bobrov el 8 de Nov. de 2012
use Statistics Toolbox
nanmean(reshape([phase(:);nan(mod(-numel(phase),25),1)],25,[]));
or use Image Processing Toolbox
blockproc(phase(:),[25,1],@(x)mean(x.data));

Iniciar sesión para comentar.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by