Borrar filtros
Borrar filtros

Mean over a multidimensionnal Cell

1 visualización (últimos 30 días)
Florian
Florian el 27 de Mzo. de 2014
Comentada: Florian el 27 de Mzo. de 2014
Hi all,
I got a cell whose form is as follow :
data{number_of_file,1}(number_of_line,number_of_columns)
I'd like to average over, for instance, the first line of the first column over all files, then the second line of the first column over all files, etc.
What would you suggest ? I've tried :
for j=1:length(data{1,1}) % loop over all lines
meanP=nanmean(data{:,1}(j,1)); % loop over all files for the j line
end
But I end up with this message : Bad cell reference operation.
Thanks
Florian

Respuesta aceptada

A Jenkins
A Jenkins el 27 de Mzo. de 2014
You want the average of per-line of all the files? If all of the data are the same number of rows, then you can concatenate them together and average the rows in one line:
data{1,1}=rand(3,3);
data{2,1}=rand(3,3);
meanP=nanmean(horzcat(data{:,1}),2); %by row
Or by column:
meanP=nanmean(vertcat(data{:,1}),1); %by column
  1 comentario
Florian
Florian el 27 de Mzo. de 2014
Thank you, I didn't know the vertcat function, newbie ;) Florian

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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