mean of matrix element
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
il147
el 5 de Oct. de 2021
Comentada: Image Analyst
el 5 de Oct. de 2021
I have trouble with meaning of matrix
I wanted to mean adt1~adt12
mean(mmadt) didn't work because of minimum matrix
how can I mean with double type?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/758951/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/758951/image.png)
2 comentarios
Willie Smit
el 5 de Oct. de 2021
What is the size of the adt12? You can get that by typing
size(adt12)
Respuesta aceptada
Image Analyst
el 5 de Oct. de 2021
mean() does not take the number of items in the second argument - that would be the dimension (direction) along which to take the mean of a matrix. Instead, try summing up and dividing.
theSum = 0;
for k = 1 : nFiles
thisFileName = fullfile(filelist(k).folder, filelist(k).name);
fprintf('Reading %s\n', thisFileName);
theSum = ncread(thisFileName, 'adt')
end
adt12Mean = theSum / nFiles
2 comentarios
Image Analyst
el 5 de Oct. de 2021
I just used the name you did, which is not normally what I'd do. I'd do this:
theSum = 0;
for k = 1 : nFiles
thisFileName = fullfile(filelist(k).folder, filelist(k).name);
fprintf('Reading %s\n', thisFileName);
theSum = ncread(thisFileName, 'adt')
end
% Compute the mean over all nFiles that we read in.
adtMean = theSum / nFiles
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulation, Tuning, and Visualization 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!