How to extract the data points from a plot using MATLAB?
1. Open the figure
2. In the MATLAB Command Window type the following commands:
h = findobj(gca,'Type','line')
x=get(h,'Xdata')
y=get(h,'Ydataâ€™)
Instead of using the "get" function, it is recommendable to use the following: x = h.Xdata;
y = h.Ydata;
The FINDOBJ function locates graphics objects with specific properties.
If there is more than one line on the plot, the GET function will return a cell array. To retrieve the numbers inside of the cell array, indexing has to be used. For example, to retrieve the points in the first line,
>> x{1} >> y{1}
Or, if the lines have the same number of points, use the CELL2MAT function. Following the example above, to retrieve the numbers inside of cell array 'x' use:
X2=cell2mat(x)

How to extract the data points from the plot using the MATLAB?