在MATLAB中提取图形文件的数据点

时间:2014-10-05 16:32:47

标签: plot matlab-figure

我导入了一个形状文件并将其保存为MAT LAB图形文件。我需要沿着图形文件的边界提取数据点为(x,y)坐标。有人可以帮我这个!

1 个答案:

答案 0 :(得分:1)

这取决于你的身材(2D图像,3D图像,图表......)。 您可以通过此命令读取图形文件

>> figFile = load('1.fig','-mat')

figFile = 

    hgS_070000: [1x1 struct]

after that you can find all data in this structure by using dot

>> figFile.hgS_070000

ans = 

          type: 'figure'
        handle: 1
    properties: [1x1 struct]
      children: [1x1 struct]
       special: []

>> figFile.hgS_070000.children
ans = 
          type: 'axes'
        handle: 176.08251953125
    properties: [1x1 struct]
      children: [1x1 struct]
       special: [4x1 double]

>> figFile.hgS_070000.children.children
ans = 
          type: 'graph2d.lineseries'
        handle: 177.0830078125
    properties: [1x1 struct]
      children: []
       special: []

>> figFile.hgS_070000.children.children.properties
ans = 
              Color: [0 0 1]
              XData: [1 2 3 4 5 6 7 8 9]
              YData: [2 1 5 6 4 8 8 4 8]
    ApplicationData: [1x1 struct]
                .
                .
                .

可以通过此

提取绘图数据
>> Y = figFile.hgS_070000.children.children.properties.YData
>> X = figFile.hgS_070000.children.children.properties.XData