【问题标题】:How to extract a matrix from a .fig in Matlab?如何从 Matlab 中的 .fig 中提取矩阵?
【发布时间】:2017-09-19 01:49:13
【问题描述】:

我有一个 Matlab .fig 文件。 (基本上是一个 pcolor 图)。我想从此图像中提取矩阵(如行和列到数组变量中)。我该怎么做呢?感谢任何输入或指针。

【问题讨论】:

    标签: image algorithm matlab image-processing matlab-figure


    【解决方案1】:

    除了 Luis Mendo 的回答,我想指出 MATLAB 支持点表示法,如果有任何性能问题,点表示法应该始终优于 set()/get() 方法。

    使用handle() 函数包装器和点表示法是设置和获取句柄类属性的最快速度。

    >> x=magic(3)
    
    x =
    
         8     1     6
         3     5     7
         4     9     2
    
    >> pcolor(x)
    >> ax = handle(gca);
    >> ax.Children.CData
    
    ans =
    
         8     1     6
         3     5     7
         4     9     2
    

    时序实验及详情见:Undocumented MATLAB

    【讨论】:

    • 感谢您的帮助
    【解决方案2】:

    轴有一个子对象,如果您使用了pcolor 函数,它是surface 类型的对象,或者如果您使用image 函数,它是image 类型的对象。该矩阵位于该对象的CData 属性中:

    >> x = magic(3) % example data
    x =
         8     1     6
         3     5     7
         4     9     2
    >> pcolor(x) % generate image
    >> get(get(gca,'Children'),'CData') % retrieve the data
    ans =
         8     1     6
         3     5     7
         4     9     2
    

    【讨论】:

    • 感谢您的意见。我现在明白了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-27
    • 2023-03-23
    • 2015-06-15
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多