필터 지우기
필터 지우기

How to obtain data in a matrix from fig.file?

조회 수: 16 (최근 30일)
maria
maria 2018년 11월 23일
답변: Star Strider 2018년 11월 23일
Hi,
A colleague gave a fig. file which is a 2D matrix with a scale color from 0 to 255. He plotted the data, saved them in a fig file a sent to me. I would like to suf the data and for that I need to extract the data. I am using for that this code:
openfig('figure.fig')
h = gcf;
axesObjs = h.Children;
dataObjs = axesObjs.Children;
data = dataObjs.CDataMapping;
But I got the error
No appropriate method, property, or field 'CDataMapping' for class 'matlab.graphics.GraphicsPlaceholder'.
What is wrong?

채택된 답변

Star Strider
Star Strider 2018년 11월 23일
The ‘Children’ propertiy disappeared with the introduction of ‘HG2’ (handle graphics version 2) in R2014b.
You most likely need to use the findobj (link) function.
Example —
figure
surf(rand(10))
h = gca;
srf = findobj(h,'Type','Surface');
X = srf.XData;
Y = srf.YData;
Z = srf.ZData;
That should return all the data you want. To see all the fields in the ‘srf’ structure, use:
sp = get(srf)
to display them.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by