フィルターのクリア

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 Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by