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

14 Ansichten (letzte 30 Tage)
SanSun
SanSun am 5 Aug. 2020
Kommentiert: Rena Berman am 8 Okt. 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 Kommentare
John D'Errico
John D'Errico am 21 Sep. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Arthur Roué
Arthur Roué am 6 Aug. 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';

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by