Filter löschen
Filter löschen

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

16 Ansichten (letzte 30 Tage)
maria
maria am 23 Nov. 2018
Beantwortet: Star Strider am 23 Nov. 2018
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?

Akzeptierte Antwort

Star Strider
Star Strider am 23 Nov. 2018
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.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by