MATLAB Answers

Plotting multiple matlab figures into a single subplot

조회 수: 3(최근 30일)
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

  댓글 수: 0

로그인 to comment.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 20 Jan 2020
편집: KALYAN ACHARJYA 20 Jan 2020
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

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by