how can I combine several file.fig together

60 vues (au cours des 30 derniers jours)
Niloufar Baba adam
Niloufar Baba adam le 28 Mar 2020
Commenté : Adam Danz 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?
  3 commentaires
Niloufar Baba adam
Niloufar Baba adam le 28 Mar 2020
my files are same as these attaches.
dpb
dpb le 28 Mar 2020
If you built the figures and saved them; it would almost certainly be far easier to do the combining of those data then on a given axis/figure or via subplot() instead of going back and retrieving from the save .fig files.
We need more detail of what you did to get these .fig files (unless they were/are from an external source in which case unless very complicated figures having the raw data as .mat file(s) would also probably be simpler) and a much clearer explanation of what your end objective should be.

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 28 Mar 2020
Modifié(e) : Adam Danz le 28 Mar 2020
It's unclear whether you want to combine each line into the same axes or if you want to combine each axes into the same figure as a set of subplots.
This demo combines the lines from all axes into 1 axes and changes their colors and legend names. The axes will have the same properties as the first copied axes.
Assumptions:
  1. Each figure contains only 1 axes
  2. Each axes contains only 1 graphics object (ie, your blue lines).
If these assumptions aren't met slight adjustments will be needed to access the desired handles.
% List figures
figureList = {'103_RU.fig','118_RU.fig'};
% List new line colors
lineCol = jet(numel(figureList));
% Open each figure and copy content
for i = 1:numel(figureList)
% Open fig-i
fighand = open(figureList{i});
% Get axis handle (assumption: only 1 axes in figure)
axHand = findobj(fighand, 'Type', 'Axes');
% on first iteration only, create new figure and
% copy the entire axis from fig-i
if i==1
fh = figure();
newAxes = copyobj(axHand, fh);
hold(newAxes, 'on')
title(newAxes,'Combined RU')
h = newAxes.Children;
else
% copy content of axes
h = copyobj(axHand.Children, newAxes);
end
% Set line color and displayname
h.Color = lineCol(i,:);
h.DisplayName = axHand.Title.String;
% Close fig-i
close(fighand)
end
% Ceate legend
legend(newAxes, 'Interpreter', 'None')
  2 commentaires
Niloufar Baba adam
Niloufar Baba adam le 28 Mar 2020
thank you so much, this is the exactly what i want.
Adam Danz
Adam Danz le 28 Mar 2020
Glad I could help. I just added a few lines to the text of my answer expaining two important assumptions the code makes.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by