Extract data from MATLAB figure (‘.fig’ file)


Extract data from ‘.fig’ file:

Sometimes I plot data and save the figure but I forget to save my workspace. If this happens to you, an easy solution is to extract data from your saved figure:

data=get(gca,'Children');
% get x and y data:
X=get(data,'XData');
Y=get(data,'YData'); 
%if there are more lines in the plot you can extract each one:
x1=cell2mat(X(1));
y1=cell2mat(Y(1));

I’ll add more solutions eventually but if you have any questions leave a comment and I’ll get back to you.

Comments

comments