How can I extract surface plot data from MATLAB figure?

22 Ansichten (letzte 30 Tage)
vasudha agrawal
vasudha agrawal am 26 Jun. 2018
Kommentiert: TheStranger am 17 Dez. 2021
I would like to extract surface plot data from saved matlab fig. I am trying using below code
ch=openfig('latching_surfplot.fig');
ch = findobj(ch,'Type','surface');
surfl(x,y,z);
ch=get(gca,'ch');
x=get(ch,'xd');
y=get(ch,'yd');
z=get(ch,'zd');
But I am getting the following error
Undefined function or variable 'x'.
*Error in surfvslineplot
surfl(x,y,z);*
Please help.
Thanks
  2 Kommentare
Walter Roberson
Walter Roberson am 26 Jun. 2018
What is your intention of having a surfl() call after you just did an openfig() ?
vasudha agrawal
vasudha agrawal am 26 Jun. 2018
If I remove surfl(), then following error came. So, I added surfl() command.
Error message: There is no xd property on the Surface class.
Error in surfvslineplot x=get(ch,'xd');

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 26 Jun. 2018
[X,Y,Z] = peaks(100) ;
surf(X,Y,Z)
h = gcf; %current figure handle
axesObjs = get(h, 'Children'); %axes handles
dataObjs = get(axesObjs, 'Children'); %handles to low-level graphics objects in axes
%%get data
XX = dataObjs.XData ;
YY = dataObjs.YData ;
ZZ = dataObjs.ZData ;
  2 Kommentare
vasudha agrawal
vasudha agrawal am 27 Jun. 2018
Thank you so much. This code is working.
TheStranger
TheStranger am 17 Dez. 2021
In the latest version one should write:
dataObjs(2).Children.XData
just fyi

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by