Borrar filtros
Borrar filtros

How can I extract Information from .FIG Files?

1 visualización (últimos 30 días)
Keith Grey
Keith Grey el 19 de Mayo de 2020
Respondida: Walter Roberson el 19 de Mayo de 2020
I have 200+ .FIG files with X & Y Data. I'm trying to do something like:
X = 1:1000;
Y1 = get(Xdata, 'Figname.fig');
Y2 = ...;
etc...
plot(X, Y1, X, Y2, etc...)

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Mayo de 2020
projectdir = 'appropriate/directory';
dinfo = dir( fullfile(projectdir, '*.fig'));
nfiles = length(dinfo);
filenames = fullfile({dinfo.folder}, {dinfo.name});
plotfig = figure();
plotax = axes('Parent', plotfig);
for K = 1 : nfiles
thisfile = filenames{K};
[~, basename, ~} = fileparts(thisfile);
fig = openfig(thisfile, 'new', 'invisible');
hasx = findobj(fig, '-property', 'XData');
xd = get(hasx, 'XData');
yd = get(hasx, 'YData');
delete(fig)
if iscell(xd)
temp = [xd(:), yd(:)].';
plot(plotax, temp{:}, 'DisplayName', basename);
else
plot(plotax, xd, yd, 'DisplayName', basename);
end
hold(plotax, 'on');
drawnow;
end
legend(plotax, 'show')
I do not assume that there is only one object with XData per figure.
I do assume that the object to be extracted from has a visible handle. This was a deliberate design decision; you could switch to findall() instead of findobj() if it is not true. One of the reasons I made the choice is that in some cases lines from legend can appear as objects that have XData property.

Categorías

Más información sobre Graphics Object Identification en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by