【问题标题】:How to automatically spin a 3d hsitogram in matlab?如何在matlab中自动旋转3d直方图?
【发布时间】:2010-01-12 10:25:57
【问题描述】:

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

谢谢

【问题讨论】:

    标签: matlab animation 3d histogram


    【解决方案1】:

    一个有点麻烦的方法是使用view 命令手动旋转图表。您可以使用此命令更新任何 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 内容的相同策略在Matlab 中使用脚本旋转绘图,但您可能希望使用pause 命令来减慢帧更改速度。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 2011-05-19
        • 2023-03-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多