Azzera filtri
Azzera filtri

mean of matrix element

2 visualizzazioni (ultimi 30 giorni)
il147
il147 il 5 Ott 2021
Commentato: Image Analyst il 5 Ott 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?
  2 Commenti
Willie Smit
Willie Smit il 5 Ott 2021
What is the size of the adt12? You can get that by typing
size(adt12)
il147
il147 il 5 Ott 2021
Modificato: il147 il 5 Ott 2021
1440*720 double
if you slide that picture, then can check other size too !

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 5 Ott 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 Commenti
il147
il147 il 5 Ott 2021
Modificato: il147 il 5 Ott 2021
then is it mean for only adt12?
I have from adt1 to adt12 and want to all of it
Adt is montly data(to 1~12), and should mean this montly data to annual data
I apologize for not good at matlab :(
Anyway, thanks for help
mean this all
Image Analyst
Image Analyst il 5 Ott 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulation, Tuning, and Visualization in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by