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 Center および File ExchangeTitle についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by