How can I combine several file.fig together
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Niloufar Baba adam
le 28 Mar 2020
Commenté : Star Strider
le 28 Mar 2020
I have several files which their formats are .fig (actually they are graphs), I need to combine them together for comparison.
could you please help me which function I can use?
0 commentaires
Réponse acceptée
Star Strider
le 28 Mar 2020
Modifié(e) : Star Strider
le 28 Mar 2020
For each .fig file:
F = openfig(filename);
Lines = findobj(F, 'Type','Line');
Then, for each element of the ‘Lines’ array:
for k = 1:numel(Lines)
x{k} = Lines(k).XData;
y{k} = Lines(k).YData;
end
It obviously depends on what information are in the .fig file, however this is the usual method for recovering the data vectors or matrices from them.
You will need to do this for each .fig file, so you will need to keep the ‘x’ and ‘y’ cell arrays separate. One way is to use an outer loop to loop through the .fig files:
for k1 = 1:NumberOfFigFiles
F = openfig(filename(k1));
Lines = findobj(F, 'Type','Line');
for k2 = 1:numel(Lines)
x{k1,k2} = Lines(k2).XData;
y{k1,k2} = Lines(k2).YData;
end
end
You can then do whatever analyses or plots you want with the ‘x’ and ‘y’ cell arrays.
EDIT — (28 Mar 2020 at 15:58)
To read them and then plot them together:
FigFile{1} = '103_RU.fig';
FigFile{2} = '118_RU.fig';
for k1 = 1:numel(FigFile)
F = openfig(FigFile{k1});
Lines = findobj(F, 'Type','Line');
for k2 = 1:numel(Lines)
x{k1,k2} = Lines(k2).XData;
y{k1,k2} = Lines(k2).YData;
end
end
figure
for k1 = 1:size(x,1)
for k2 = 1:numel(x,2)
plot(x{k1,k2}, y{k1,k2})
hold on
end
end
hold off
grid
xlim([0.5 7])
ylim([0 4])
2 commentaires
Star Strider
le 28 Mar 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots 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!