gpt4 book ai didi

matlab - 使用散点图可视化大型 3D 数据集

转载 作者:行者123 更新时间:2023-12-01 18:18:39 25 4
gpt4 key购买 nike

我正在 MATLAB 中运行模拟,其中有一个大型 3D 数据集,每个时间步长都会发生变化。我尝试使用 3D 散点图来可视化数据,其中随着模拟的进行,点会呈现不同的位置、大小、颜色和透明度级别。尺寸和颜色信息是多余的。

在 MATLAB 中渲染和旋转图形速度缓慢且不稳定。我的电脑配备 4 GHz i7-4790 CPU 和 NVIDIA GeForce GTX 750 Ti 显卡。我在 Windows 7 上使用 Matlab R2016a。我检查了我的 MATLAB OpenGL 设置,硬件支持级别已满。 (硬件 OpenGL 对于透明度是必要的。)此外,我正在使用 GPU-Z 监控我的 GPU 使用情况。 ,在绘图和旋转过程中,GPU 负载峰值仅为 25-30%。

这是我的代码示例:

load sample_data2
channels_matrix = cat(1, channels{:});
num_channels = length(channels);
channel_lengths = cellfun(@(x) size(x, 1), channels);

figure(1);
for i = 1:num_channels
g = plot3(channels{i}(:, 1), channels{i}(:, 2), channels{i}(:, 3), 'k');
set(g, 'LineWidth', 1.5)
hold on;
text(channels{i}(1, 1), channels{i}(1, 2), channels{i}(1, 3), num2str(i))
end
caxis([0 1])
colorbar
drawnow

numDivisions = 8;
ptsPerDivision = numel(grid_x)/numDivisions;
T = 1000;
numplotpts = 2E4;
for t = 1:T
plot_signal = nan(size(grid_x));
plot_signal(sort(randsample(numel(grid_x), numplotpts))) =...
sort(rand(numplotpts, 1));
tic
for i = 1:numDivisions
temp = plot_signal(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
yplot = grid_y(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
xplot = grid_x(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
zplot = grid_z(dists_idx((i-1)*ptsPerDivision+1:i*ptsPerDivision));
if t == 1
h(i) = scatter3(yplot(~isnan(temp)), xplot(~isnan(temp)),...
zplot(~isnan(temp)), 50*temp(~isnan(temp)), temp(~isnan(temp)), ...
'filled', 'MarkerFaceAlpha', exp(-i)^0.25);
else
h(i).XData = yplot(~isnan(temp));
h(i).YData = xplot(~isnan(temp));
h(i).ZData = zplot(~isnan(temp));
h(i).SizeData = 50*temp(~isnan(temp));
h(i).CData = temp(~isnan(temp));
end
end
drawnow
toc
end

这是指向 data 的链接。有什么办法可以加快渲染速度并使旋转更平滑吗?我注意到将所有数据点的大小固定为单个标量可以大大加快渲染和旋转速度。是否可以保持代码中的大小,并且仍然使图形快速渲染和旋转?

编辑:A related question我发帖了。

最佳答案

听起来计时器功能是下一步尝试的好地方,以便了解模拟的进展情况,然后在对事物的外观感到满意后制作 AVI。

MATLAB 有一些很棒的 documentation为此,有多种选项可用于连续调用以及它们之间的间距。查看 ExecutionModePeriod 属性。

关于matlab - 使用散点图可视化大型 3D 数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45527467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com