Error Using Accumarray "Requested array exceeds the maximum possible variable size"
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andrew Stark
le 25 Nov 2020
Commenté : Walter Roberson
le 26 Nov 2020
I am trying to generate a histogram but I keep on getting this error
Error using accumarray
Requested array exceeds the maximum possible variable size.
Error in Analyze (line 170)
zm=accumarray([Dfr' Zfr'],1,[nn nn]);
My code is here
n=100;
for i=1:1
ZZ=Zf{i};
DD=Df{i};
nn=repelem(n,144);
Zf2=linspace(min(ZZ(:)),max(ZZ(:)),n);
Df2=linspace(min(DD(:)),max(DD(:)),n);
Zfr=interp1(Zf2,1:numel(Zf2),ZZ,'nearest');
Dfr=interp1(Df2,1:numel(Df2),DD,'nearest');
zm=accumarray([Dfr' Zfr'],1,[nn nn]);
figure, surf(zm);
hold on
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/428463/image.jpeg)
A segment of Df and Zf are pictured above
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/428468/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/428473/image.jpeg)
0 commentaires
Réponse acceptée
Walter Roberson
le 25 Nov 2020
Modifié(e) : Walter Roberson
le 25 Nov 2020
nn=repelem(n,144);
That is a vector of 144 copies of 100
[nn nn]
that puts two of those together, getting a 1 x 288 vector of 100's.
You are requesting that accumarray create an output that is 100^288 elements.
There are only roughly 3*10^80 particles in the observable universe.
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!