plot figures using a for loop and subplot function
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
KSSV
on 14 Feb 2022
Edited: KSSV
on 14 Feb 2022
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 Comments
See Also
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!