MATLAB: How to get object data from a FIG file, such as X and Y data

datagrabbing datagraphplotxy

i search on matlab searching question but not found it.
I have a graph with a curve. I want to know the Y value from my graph
example X = 10
how to find Y?
thx.

Best Answer

Open the figure using “openfig” and return the “Figure” object as an output argument, such as "fig". Then use “fig” to access the underlying objects in the figure.
fig = openfig('MySavedPlot.fig')
For example, if the figure contains a line plot, you might want to get the X and Y data for the line. You can get the X and Y data using the XData and YData properties of the "Line" object. You can access the "Line" object through the "Children" property of the axes. You can access the "Axes" object through the “Children” property of the figure.
ax = fig.Children
ln = ax.Children;
X = ln.XData;
Y = ln.YData;