Hold on command for ode45 plot
1 view (last 30 days)
Show older comments
Hi everybody! I am doing some exercises on solving systems of differential equations. I wanted to plot many solution curves on the same figure so I made a for loop:
for i=0:6
[t, x] = ode45(@exc_345, [-4 4], [-i i]);
hold on
plot(x(:,1),x(:,2));
hold off
end
It worked but now I saw that it is not "correct": the hold on and hold off commands would have to be out of the loop. Why does it work anyway? Thanks.
0 Comments
Accepted Answer
Jan
on 30 Dec 2014
The hold off is overridden by the following hold on. So you can omit the hold off. The repeated call of hold on does not matter also, because the main action is that the 'NextPlot' property of the current plot is set to 'add'. Doing this repeatedly is not a problem.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!