How to extract data from multiple Matlab figures

25 visualizzazioni (ultimi 30 giorni)
Hello everyone, I have extracted data from Matlab figure saved in “.fig” format by using the following code
open F1.fig %%F1.fig is the first figure
D = get(gca, 'children')
x=get(D, 'xdata');
x, y, and z are the extracted data of x,y and z components.For only one case I have total 90 figures so by using the above code for each figure take much time. Now I need to use the above code for all 90 figures and get the data at once. I tried by using for loop but it does not work. Thanks

Risposta accettata

Walter Roberson
Walter Roberson il 4 Dic 2017
Modificato: Walter Roberson il 4 Dic 2017
dinfo = dir('*.fig')
fignames = {};
numfig = length(fignames);
x = cell(numfig, 1);
y = cell(numfig, 1);
z = cell(numfig, 1);
for K = 1 : numfig
figfile = fignames{K};
fig = openfig(figfile);
ax = get(fig, 'CurrentAxes');
if ~isempty(ax)
D = get(ax, 'Children');
x{K} = get(D, 'XData');
y{K} = get(D, 'YData');
z{K} = get(D, 'ZData');
fprintf('note: file "%s" has empty current axes\n', figfile);
catch ME
fprintf('note: file "%s" could not be opened as figure\n', figfile);
  5 Commenti
Safi ullah
Safi ullah il 5 Dic 2017
@ Walter Roberson thanks. Now I found it work good.

Accedi per commentare.

Più risposte (0)


Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by