8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Safi ullah il 4 Dic 2017
Commentato: Safi ullah il 5 Dic 2017
Risposta accettata: Walter Roberson
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');
y=get(D,'ydata');
z=get(D,'cdata');
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
0 Commenti Mostra -2 commenti meno recentiNascondi -2 commenti meno recenti
Mostra -2 commenti meno recentiNascondi -2 commenti meno recenti
Accedi per commentare.
Accedi per rispondere a questa domanda.
Risposta accettata
Walter Roberson il 4 Dic 2017
Modificato: Walter Roberson il 4 Dic 2017
dinfo = dir('*.fig')
fignames = {dinfo.name};
numfig = length(fignames);
x = cell(numfig, 1);
y = cell(numfig, 1);
z = cell(numfig, 1);
for K = 1 : numfig
figfile = fignames{K};
try
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');
else
fprintf('note: file "%s" has empty current axes\n', figfile);
end
close(fig);
catch ME
fprintf('note: file "%s" could not be opened as figure\n', figfile);
end
end
5 Commenti Mostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Mostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Safi ullah il 4 Dic 2017
Link diretto a questo commento
https://it.mathworks.com/matlabcentral/answers/371014-how-to-extract-data-from-multiple-matlab-figures#comment_512526
@y Walter Roberson thanks for response actually your given code is good but it does not give x,y and z component for each figure. For example, I have 90 figures and for each figure x=1*8, y=1*33 and z=133*8. I need to save these three components for each fig also.
Walter Roberson il 5 Dic 2017
Link diretto a questo commento
https://it.mathworks.com/matlabcentral/answers/371014-how-to-extract-data-from-multiple-matlab-figures#comment_512610
Are you trying to recreate the x, y, and z that were used to create a plot using
plot3(x, y, z)
where x and y were vectors and z was a 2D array?
https://www.mathworks.com/matlabcentral/answers/100687-how-do-i-extract-data-from-matlab-figures#comment_512527
Safi ullah il 5 Dic 2017
Link diretto a questo commento
https://it.mathworks.com/matlabcentral/answers/371014-how-to-extract-data-from-multiple-matlab-figures#comment_512683
Modificato: Safi ullah il 5 Dic 2017
@ Walter Roberson, I do not try for plotting plot3(x, y, z). I need to extract x,y and z components of each figure and then saved all x components separately, all y components separately and all z components separately.
Walter Roberson il 5 Dic 2017
Link diretto a questo commento
https://it.mathworks.com/matlabcentral/answers/371014-how-to-extract-data-from-multiple-matlab-figures#comment_512692
That is what my code already does. It creates cell arrays, x, y, and z, each of which has one entry per figure. For figures in which there was only one axes child, the entry will be a numeric vector. For figures in which there was more than one axes child, the entry will be a cell array of numeric vectors, one entry per child.
You have a number of figures, and each figure has an unknown number of axes children, so you nested structures are to be expected.
Safi ullah il 5 Dic 2017
Link diretto a questo commento
https://it.mathworks.com/matlabcentral/answers/371014-how-to-extract-data-from-multiple-matlab-figures#comment_512713
@ Walter Roberson thanks. Now I found it work good.
Accedi per commentare.
Più risposte (0)
Accedi per rispondere a questa domanda.
Vedere anche
Categorie
MATLABGraphicsFormatting and AnnotationLabels and AnnotationsAnnotations
Scopri di più su Annotations in Help Center e File Exchange
Tag
- extract data
- for loop
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia-Pacifico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contatta l’ufficio locale