【问题标题】:scatter plot: tall arrays eating up all the memory散点图:高大的数组占用了所有内存
【发布时间】:2018-09-17 20:51:27
【问题描述】:

我正在研究 HDR 中的色调映射运算符。我的问题很简单。我想用计算机规格核心 i5 20GB RAM 在 Matlab 2015Ra 上散点图大型数组。只有散点图会占用整个内存(大约 20GB 的 92%)。我需要一些建议来绘制 tall 数组。我知道 Matlab 2018 具有 binscatter 功能,但我的版本较低。谢谢你。示例代码:

a=randn(21026304,1);
scatter(a,a); 

只有这段代码会占用所有内存。

【问题讨论】:

标签: arrays matlab matlab-figure scatter-plot


【解决方案1】:

您可以使用histcounts2 自己创建一个binscatter 类似功能! Histcounts 将数据放入一个 NxN 数组中,然后您可以使用 imshow 对其进行可视化...这非常节省内存,因为每个 bin 仅占用几个字节,而与输入大小无关。

% Some (correlated) data
x = randn(1e6,1);
y = randn(1e6,1)+x;

% Count 32x32 bins
[N,ax,ay] = histcounts2(x,y,32);

% Some gradient
cmap = [linspace(1,0,16);
    linspace(1,0.3,16);
    linspace(1,0.5,16)].';

% Show the histogram
imshow(...
    N,[],...                        % N contains the counts, [] indicated range min-max
    'XData', ax, 'YData', ay, ...   % Axis ticks
    'InitialMagnification', 800,... % Enlarge 8x
    'ColorMap', cmap...             % The colormap
);

colorbar;       
axis on;
title('bin-counts');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 2012-03-30
    • 2013-01-22
    • 2019-08-30
    相关资源
    最近更新 更多