Animation of multiple Quivers

조회 수: 11 (최근 30일)
Jonas Giebeler
Jonas Giebeler 2023년 2월 12일
답변: Adam Danz 2023년 2월 12일
Hello,
my problem is a bit more complex but it can basically be broken down to the followning:
I have 2 vectors where one vector starts at the end of the first one. I want to create an animated plot with a "for loop" where the first vector is stationary and the second one rotates by 360° around the end of the first one. My problem is, that i can only create 2 quivers in one plot by using the "hold" command, which then also holds each of the 360° animated timesteps. This is not the intended result because i want to create a rotating vector and not a series of multiple vectors.
Is there a way to solve this ?

답변 (1개)

Adam Danz
Adam Danz 2023년 2월 12일
The hold command merely prevents the axes from being cleared when you add new graphics objects to the axes. You can manipulate the values of a quiver arrow during the for-loop. quiverrotate from the file exchange might come in handy although it sounds like you could achive this without using a 3rd party function.
Example:
h = quiver([0 1],[0 0],[1 0],[0 1],'off','LineWidth',2);
axis equal
xlim([-0.5 2.5])
ylim([-1 1])
grid on
theta = linspace(pi/2,2.5*pi,20);
[u,v] = pol2cart(theta,ones(size(theta)));
for i = 1:numel(theta)
h.UData(2) = u(i);
h.VData(2) = v(i);
drawnow
end

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by