Reputation: 517
I have a matlab .fig file which contains some points and a surface fitted to them. I want to extract the surface from the figure, and I would like to have both the vertices and the faces. Could you please provide me some hints on how to achieve this?
My figure can be found here: https://drive.google.com/file/d/0By376R0mxORYU3JsRWw1WjllWHc/view?usp=sharing and I would like to extract the surface without the blue points.
EDIT: it is not a duplicate, see my comment below as to why.
Upvotes: 1
Views: 569
Reputation: 5190
The data used to plot either the surface and the dots are stored in the figure.
Therefore you can:
The axes actually contains two set of data:
XData
, YData
, ZData
XData
, YData
, ZData
This is the code (with "dot notation"):
% Open the figure
open('cubicinterp.fig')
% Get the data from the figure
x=gcf
% Get the children of the figure (in this case the axes)
y=x.Children
% Get the data used to plot on the axes
z=y.Children
figure
XX=z(2).XData;
YY=z(2).YData;
ZZ=z(2).ZData;
CCDD=z(2).CData;
surf(XX,YY,ZZ,CCDD)
return
This is the code without the "dot notation" (before R2014b)
% Open the figure
open('cubicinterp.fig')
% Get the data from the figure
x=gcf
% Get the children of the figure (in this case the axes)
y_1=get(gcf,'children');
% Get the data used to plot on the axes
z_1=get(y_1,'children');
figure
XX=get(z_1(2),'xdata');
YY=get(z_1(2),'ydata');
ZZ=get(z_1(2),'zdata');
CCDD=get(z_1(2),'Cdata');
surf(XX,YY,ZZ,CCDD)
This is the extracted surface:
Hope this helps.
Qapla'
Upvotes: 2