How can I 'hold off' specific Field vector using "quiver" into a updated "drawnown" inside a plot?
Show older comments
Hello!
I wanted to make an animation using "quiver" function. The problem is that the "drawnow" is plotting over and over the previous field vectors each iteration of 'for' loop ("overdrawning"). I wanted to "erase" the previous plots, and keep the last plot (updating plot to plot).
Some example:
%-------------//----------------------
(function1)
(plot1 the function above)
hold on
for idx=1:nImages
Ma=quiver(idx) over plot1
drawnow
hold off (erase only the previous quivers, not current quiver updated & plot1; so, hold the last quiver)
end
%---------//---------------------
The problem using 'hold off' is that it erases all plots and quiver, but the 'plot1' was erased also.
I've tried to use hold(Ma,'off'), but the error happened:
"Error using hold (line 52)
First argument must be an axes object."
I think it means that 'hold' doesn't accept "quiver", only common plottings.
If someone can help me about that I will be grateful!!
Thanks! (from Brazil)
Accepted Answer
More Answers (1)
Mitchell Thurston
on 12 Dec 2021
I'm assuming you're calling quiver in the "quiver(x,y,u,v)" style, since you can't use 1 argument
% After plot 1 is made
hold on
Ma = quiver([NaN],[NaN],[NaN],[NaN]);
for i = 1:nImages
set(Ma, 'XData', x(i,:), 'YData', y(i,:), 'UData', dx(i,:), 'VData', dy(i,:));
drawnow
% would likely want to add a pause(0.1) here so you can see it
% changing in real time
end
I'm not sure what arguments you're using on quiver, so I used names that made sense. Hopefully this helps.
1 Comment
Igor Rocha
on 13 Dec 2021
Categories
Find more on Vector Fields 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!