필터 지우기
필터 지우기

plot figures using a for loop and subplot function

조회 수: 1 (최근 30일)
Mohammed Rabani
Mohammed Rabani 2022년 2월 14일
편집: KSSV 2022년 2월 14일
I have a dataset of around 180 columns of data to be plotted with respect to another constant dataset. My initial try was to plot the datasets using a for loop for different combinations of the data using a looping command and subplot function. I have succeeded in plotting for around 15-20 but then i noticed that the loop command cannot be fixed at the next index for the next set of plots.
for i = 1:15
subplot (5,3,i)
plot (outdoor_temp,D(:,i), "r *")
xlabel ('Outdoor tempe(C)')
ylabel ('Energy load')
title (var{i})
end
for i = 16:30
subplot (5,3,i)
plot (outdoor_temp,D(:,i), "r *")
xlabel ('Outdoor tempe(C)')
ylabel ('Energy load')
title (var{i})
end

답변 (1개)

KSSV
KSSV 2022년 2월 14일
편집: KSSV 2022년 2월 14일
If you want in two different figure:
figure(1)
for i = 1:15
subplot (5,3,i)
plot (outdoor_temp,D(:,i), "r *")
xlabel ('Outdoor tempe(C)')
ylabel ('Energy load')
title (var{i})
end
figure(2)
for i = 16:30
subplot (5,3,i-15) % <---- subtract 15 here
plot (outdoor_temp,D(:,i), "r *")
xlabel ('Outdoor tempe(C)')
ylabel ('Energy load')
title (var{i})
end

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by