'hold on' not working with for loop
9 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to plot multiple lines on the same graph using a for loop:
for i=1:imax
path=raypath3(frange(i), hnprofile, ds, minang, maxang, angstep, xmax);
plot(path(1,:),path(2,:))
hold on
end
hold off
When I run the code, it plots each line on a separate graph (so if imax is 3, I end up wih 3 different graphs). The hold on command doesn't seem to be doing anything. I've looked at similar questions that have already been asked but none of them have fixed my problem.
EDIT:
I have fixed the problem! I needed to create a figure and say hold on before the for loop.
figure
hold on
for i=1:imax
path=raypath3(frange(i), hnprofile, ds, minang, maxang, angstep, xmax);
plot(path(1,:),path(2,:))
end
(I also didn't need to say hold off at the end).
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!