Matlab Tricks

Getting datapoints from Matlab figures


Sometimes it’s necessary to get the data-points out of a matlab figure (though it typically happens years after the original was made and with no scripts to rerun). I can never seem to remember how to do this. I found a good description posted elsewhere on a blog called Memming’s Inconsistency. Since I’m not sure how inconsistent that source will be in the future, I’ll put the commands here too.

Basics :

>>axes_loc =get(gcf,’Children);

>>info=get(axes_loc(1),’Children&rsquoWinking;

>>get(info)

will then provide a huge list of the properties in the 1st plot on the figure.

x_data = get(info,’XData&rsquoWinking; y_data = get(info,’YData&rsquoWinking;

that’ll do it. For plots with multiple curves, you’ll need to pull them out from arrays, but by this point it’s within my ability to remember. The above is what I can never seem to recall and always resort to Google searches to find.

Then use x_data{1} and y_data{1} to get the values for the first plot in the series. Und so weiter...