Effacer les filtres
Effacer les filtres

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

16 vues (au cours des 30 derniers jours)
maria
maria le 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?

Réponse acceptée

Star Strider
Star Strider le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by