Why is my subplot in for loop only plotting in one of the figures?
15 次查看(过去 30 天)
显示 更早的评论
Hi! I'm trying to figure out why my code isn't working? My code is only displaying the values in the second subplot, and I don't know why it does that?
level = 1:25;
streakvalue = [0 60 120 180 240 300 360 420 480];
for i = 1:length(streakvalue)
hold all
old = 110 + streakvalue(i) + level * 9.9;
subplot(1,2,1);plot(old,level);yticks(1:2:25);grid on
new = 100 + streakvalue(i) + level * 8;
subplot(1,2,2);plot(new,level);yticks(1:2:25);grid on
end
0 个评论
采纳的回答
the cyclist
2016-12-13
The behavior of the "hold" command is sometimes a little counterintuitive.
Try this
level = 1:25;
streakvalue = [0 60 120 180 240 300 360 420 480];
figure
for i = 1:length(streakvalue)
old = 110 + streakvalue(i) + level * 9.9;
subplot(1,2,1); hold all; plot(old,level); yticks(1:2:25);grid on
new = 100 + streakvalue(i) + level * 8;
subplot(1,2,2); hold all; plot(new,level); yticks(1:2:25);grid on
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!