Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

The mean in the accumarray exceeds the maximum value in the array, which it shouldn't.

1 Ansicht (letzte 30 Tage)
Aristo
Aristo am 5 Mär. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Please find the link for the code: THE LINK
In this particular code, the mean exceeds the maximum value in the array, which it shouldn't. What is the other approach? For example i have values between [0 1]. But the mean values are sometimes 1.5.
  1 Kommentar
Matt J
Matt J am 5 Mär. 2019
Bearbeitet: Matt J am 5 Mär. 2019
Please attach the data which is producing this result in a .mat file. Also, please post the code you are actually running to generate the result, not the summary of it at the link.

Antworten (1)

Steven Lord
Steven Lord am 5 Mär. 2019
I am not able to reproduce this behavior on my Windows machine running release R2018b. Can you show the result of this code?
rng default
npt = 10000;
A = [rand(npt,1)*180-90 rand(npt,1)*360-180 rand(npt,1)];
latbin = -90:5:90;
lonbin = -180:5:180;
nlat = length(latbin);
nlon = length(lonbin);
ilat = discretize(A(:,1), latbin);
ilon = discretize(A(:,2), lonbin);
idx = sub2ind([nlat nlon], ilat, ilon);
altg = accumarray(idx, A(:,3), [nlat*nlon 1], @(x) mean(x), NaN);
anyValuesInAltgGreaterThan1 = any(altg(:) > 1)
maximumValueInAltg = max(altg(:))
If that code is not sufficient to reproduce the behavior, please post code with which you can along with information about which OS you're using and which release of MATLAB.
And just because I'm suspicious, can you post the output of this command as well?
which -all mean

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by