How to extract data from a saved MATLAB figure?
I have a saved shape ( .Fig
) containing axes like this:
When I open this shape in MATLAB R2015a GUIDE, I have the following:
Is there anyway to fetch data from all axes in this figure? If not, is there anyway to extract one of the axes in the drawing and use it in another drawing generated by GUIDE?
+3
source to share
1 answer
Assuming the figure of interest is the current metric:
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
+2
source to share