How to open multiple figures and combine them into a new figure

10 visualizaciones (últimos 30 días)
SanSun
SanSun el 5 de Ag. de 2020
Comentada: Rena Berman el 8 de Oct. de 2020
Hello, I have multiple open figures. I want to create a new figure containing all the figures. How can I do this?
I tried this :
clear all
clc
%%Oppening figure
rep = 'C:s';
if exist(rep, 'file')~=7
error('Le dossier n''existe pas');
end
ext = '*.fig';
chemin = fullfile(rep,ext);
list = dir(chemin);
nFig = length(list);
figure; % new figure
for n = 1:nFig
filename = fullfile(rep,list(n).name);
f_c = openfig(filename,'reuse');
ha1 = get(gca(n+1),'Children'); %this returns the children of the axes
a1 = get(ha1,'Xdata'); % obtain the XData
b1 = get(ha1,'Ydata'); % obtain the YData
% close('all')
hold on
plot(a1,b1) %plot the data again
dockfig('all')
end
nFig = length(list);
figure; % new figure
for n = 1:nFig
filename = fullfile(rep,list(n).name);
f_c = openfig(filename,'reuse');
ha1 = get(gca(n+1),'Children'); %this returns the children of the axes
a1 = get(ha1,'Xdata'); % obtain the XData
b1 = get(ha1,'Ydata'); % obtain the YData
% close('all')
hold on
plot(a1,b1) %plot the data again
dockfig('all')
end
Any help will be appreciated. Thanks!
  7 comentarios
John D'Errico
John D'Errico el 21 de Sept. de 2020
Note that when you remove your question, you damage answers as a site, since this makes the question useless for anyone else to ever learn from. This insults both the person who wasted their time in answering your question, as well as anyone who might otherwise have also gained from this answer.
If you cannot bear to leave your question in the public, then you should not post in the first place.

Iniciar sesión para comentar.

Respuestas (1)

Arthur Roué
Arthur Roué el 6 de Ag. de 2020
According to your figures, I came with that :
% Get figure handles to merge
hFig_1 = openfig(fullfile(pwd, 'figure_1.fig'));
hFig_2 = openfig(fullfile(pwd, 'figure_2.fig'));
% Find line in axe 2 to copy it into axe 1
hAxe_1 = findobj(hFig_1, 'type', 'Axes');
hLine_2 = findobj(hFig_2, 'type', 'Line');
% Copy line
hLine_21 = copyobj(hLine_2, hAxe_1);
% Change new line style
hLine_21.LineStyle = '--';
hLine_21.Color = 'b';

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by