Clear Filters
Clear Filters

How to call a saved fig file

3 views (last 30 days)
영탁 한
영탁 한 on 15 Feb 2023
Answered: Jai Khurana on 15 Feb 2023
I want to output multiple saved fig files to one figure. I would appreciate it if you could tell me how.

Answers (1)

Jai Khurana
Jai Khurana on 15 Feb 2023
Hi,
To output multiple saved fig files to one figure, you can use the "openfig" function to open each saved fig file as a separate figure, and then copy the contents of each figure to a single figure using the "copyobj" function. Here's an example code snippet that demonstrates this:
% Specify the file names of the saved fig files
fileNames = {'figure1.fig', 'figure2.fig', 'figure3.fig'};
% Create a new figure to combine the saved fig files
combinedFig = figure();
% Loop through each saved fig file
for i = 1:length(fileNames)
% Open the saved fig file as a separate figure
figHandle = openfig(fileNames{i});
% Get the handle to the axes object in the separate figure
axesHandle = gca(figHandle);
% Copy the axes object from the separate figure to the combined figure
copyobj(axesHandle, combinedFig);
% Close the separate figure
close(figHandle);
end

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!