plot figures using a for loop and subplot function
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!