如何在matlab中自动旋转3D直方图?

发布于 2024-08-17 12:48:57 字数 96 浏览 2 评论 0原文

我在 matlab 中有一个 3d 直方图。是否可以自动旋转它以获得 3D 效果。我想在 PowerPoint 中将其显示为视频,其中 3d 直方图会旋转。

谢谢

I have a 3d histogram in matlab. Is it possible to automatically spin it i.e to get the 3d effects. I want to show it as a video in PowerPoint where the 3d histogram swivels.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

彻夜缠绵 2024-08-24 12:48:58

执行此操作的一种有点麻烦的方法是使用 查看命令。您可以使用此命令更新任何 3D 绘图的方位角和仰角视图。

创建它的视频需要使用这样的命令序列捕获绘图窗口(注意,您将获得灰色背景,因此您可能想要更改背景颜色):

% create figure and get handle to it (store handle in hf)
hf = figure(1);

% [create 3d plot]

% Create file to hold the animation
aviobj = avifile('mymovie.avi', 'compression', 'Cinepak');

% loop with some criteria for rotation
while(...)
    % update view using view command
    view(az, el);

    % get Matlab to flush the drawing buffer (effectively forces a plot update)
    drawnow;

    % capture frame and write to the avi file
    aviobj = addframe(aviobj, hf);
end
% end loop

% Close movie (flushes write buffer and finishes the video)
aviobj = close(aviobj);

您可以使用相同的策略,而无需 avifile stuff 使用 Matlab 中的脚本来旋转绘图,尽管您可能希望使用 pause 命令来减慢帧更改速度。

A somewhat cumbersome way to do this would be to rotate the chart manually using the view command. You can update azimuth and elevation views of any 3D plot using this command.

Creating a video of it requires capturing the plot window using a command sequence like this (note, you're going to get the gray background, so you might want to change the background color):

% create figure and get handle to it (store handle in hf)
hf = figure(1);

% [create 3d plot]

% Create file to hold the animation
aviobj = avifile('mymovie.avi', 'compression', 'Cinepak');

% loop with some criteria for rotation
while(...)
    % update view using view command
    view(az, el);

    % get Matlab to flush the drawing buffer (effectively forces a plot update)
    drawnow;

    % capture frame and write to the avi file
    aviobj = addframe(aviobj, hf);
end
% end loop

% Close movie (flushes write buffer and finishes the video)
aviobj = close(aviobj);

You can use the same tactic without the avifile stuff to rotate the plot using a script in Matlab, though you might want to use a pause command to slow down the frame change.

春花秋月 2024-08-24 12:48:58

让我们确保我们在这里谈论的是同一件事。二维直方图将具有指定 X 和 Y 范围的箱,并且计数将显示在 Z 轴上。 3-D 直方图在 X、Y 和 Z 范围内有箱,并以其他方式(颜色?)显示计数。您需要对 3-D 直方图进行切片才能有意义。我假设您的意思是二维直方图,看起来像一堆从地下冒出来的块。

我认为您最好将此二维直方图制作成图像,其中每个像素代表 X 和 Y 中的特定容器,颜色指定该容器中的计数。我认为这项动议只会混淆数据。为此,请使用 image 或 imagesc 或 imshow。另外,我建议使用基于强度的颜色图(>>颜色图),例如春天或冬天。这使得差异更加明显。打开颜色条(>>颜色条)

Let us make sure we are talking about the same thing here. A 2-D histogram would have bins of a specified X and Y range and the count would be shown on a Z axis. A 3-D histogram would have bins in the X and Y and Z ranges with the count shown in some other way (color?) You would need slicing for a 3-D histogram to make sense.I am going to assume that you mean a 2-D histogram that looks like a bunch of blocks coming out of the ground.

I think you will be better served to make this 2-D histogram into an image, where each pixel represents a specific bin in X and Y and the color specifies the count in that bin. I think the motion will only confuse the data. Use image or imagesc or imshow for this. Also, I would recommend an intensity based colormap (>>colormap), like spring or winter. This make the differences more apparent. Turn on the colorbar (>>colorbar)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文