Plotting multiple matlab figures into a single subplot

I used this script to plot 4 matlab figures located in my desktop into a single plot:
Names of the figures: Idc_C1,Idc_C2,Idc_C3 and Idc_C4
clear all;
clc;
c=zeros(4,1);
h=zeros(4,1);
for i=1:4
h(i)=subplot(2,2,i);
end
for k=1:4
% Load saved figures
c(k)=hgload(strcat('C:\Users\kannan\Desktop\PSCAD_Automation_Modell_4T_HBFB\04_Plots\CASE_C1_SEQ_S1\Idc_C',num2str(k)));
% Prepare subplots
figure
% Paste figures on the subplots
copyobj(allchild(get(c(k),'CurrentAxes')),h(k));
end
The problem with the code is that it creates certain duplicated empty figures after the creation of the original subplot.
How should I modify the code to avoid the generation of the empty matlab figures.
Any sugestions or assistance would be very helpful.
problem.png

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 1월 20일
편집: KALYAN ACHARJYA 2020년 1월 20일
Remove figure statement within the loop.
clear all;
clc;
c=zeros(4,1);
h=zeros(4,1);
for i=1:4
h(i)=subplot(2,2,i);
end
for k=1:4
c(k)=hgload(strcat('C:\Users\kannan\Desktop\PSCAD_Automation_Modell_4T_HBFB\04_Plots\CASE_C1_SEQ_S1\Idc_C',num2str(k)));
copyobj(allchild(get(c(k),'CurrentAxes')),h(k));
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by