How can I extract surface plot data from MATLAB figure?

조회 수: 10 (최근 30일)
vasudha agrawal
vasudha agrawal 2018년 6월 26일
댓글: TheStranger 2021년 12월 17일
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
Walter Roberson
Walter Roberson 2018년 6월 26일
What is your intention of having a surfl() call after you just did an openfig() ?
vasudha agrawal
vasudha agrawal 2018년 6월 26일
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');

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 6월 26일
[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
vasudha agrawal
vasudha agrawal 2018년 6월 27일
Thank you so much. This code is working.
TheStranger
TheStranger 2021년 12월 17일
In the latest version one should write:
dataObjs(2).Children.XData
just fyi

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by