Search code examples
plotmatlab-figure

Extract data points of figure file in MAT LAB


I have imported a shape file and save it as a MAT LAB figure file. I need to extract data points along the boundary of the figure file as (x,y) coordinates. can someone help me with this!


Solution

  • It depends on your figure (2D image, 3D image , chart ,...). You can read a fig files by this command

    >> 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]
                    .
                    .
                    .
    

    Ploted data can be extracted by this

    >> Y = figFile.hgS_070000.children.children.properties.YData
    >> X = figFile.hgS_070000.children.children.properties.XData