Plotting areas in a for loop
1 次查看(过去 30 天)
显示 更早的评论
I am trying to plot areas inside a for loop. However, only the area for the final pass of the loop is plotting.
ylim = get(gca, 'Ylim');
for k = 1:length(explosions);
area([explosions(k, 1) explosions(k, 2)], [ylim(2) ylim(2)]);
end
The explosions vector is a 26x2 matrix that contains the start and end time of the area to plot in the first and second column respectively.
0 个评论
采纳的回答
Star Strider
2017-2-13
Without seeing the rest of your code, I can only guess) that you are not using the hold function.
Try something like this:
figure(1)
ylim = get(gca, 'Ylim');
for k = 1:length(explosions);
area([explosions(k, 1) explosions(k, 2)], [ylim(2) ylim(2)]);
hold on
end
hold off
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!