我正在MATLAB中运行一个模拟,其中我有一个可以更改每个时间步的大型3D数据集。我正在尝试使用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 我发布了。
它是否需要在实时或你可以渲染它作为一个电影(.avi)以后更流畅的播放? – informaton
实时并不是一项要求,但它是首选。 –
我在代码中调用了大约0.5秒的延迟(例如tic/toc)。你现在在做什么? – informaton