3

I have a saved figure (.Fig) containing some axes like this:

enter image description here

When I open this figure in MATLAB R2015a GUIDE I have this:

enter image description here

Is anyway to extract data from every axes in this figure? If not, is anyway to extract one of the axes in the figure and use it in another figure created by GUIDE?

Eghbal
  • 3,892
  • 13
  • 51
  • 112

1 Answers1

2

Assuming the figure of interest is the current figure:

ax = get(gcf,'children'); % get all subplots
X=[];Y=[];
for iax = 1:length(ax)
    child = get(ax(iax),'children'); % for each subplot, get all lines
    for ichild = 1 : length(child)
        X{end+1} = get(child(ichild),'xdata');
        Y{end+1} = get(child(ichild),'ydata');
    end     
end
Itamar Katz
  • 9,544
  • 5
  • 42
  • 74
  • Thank you for answer. As you can see in first figure, we have two sets of data in every axes(black line and red line). This code extract both lines data? – Eghbal Jul 17 '15 at 19:19
  • 1
    Yes, that what the inner loop is for. But keep in mind it works for 'line' type of data, which has 'xdata' and 'ydata' properties (not all graphic elements have these properties) – Itamar Katz Jul 17 '15 at 19:24
  • I can't up-vote it! I think i should edit the answer for up-voting. – Eghbal Jul 19 '15 at 07:00