How to move a marker along line in polar coordinate
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ロン
el 10 de Feb. de 2023
Comentada: Sulaymon Eshkabilov
el 10 de Feb. de 2023
I want to draw a point that can move along to the Lemniscate of Bernoulli in polar coordinate. The example to move object along to a line is shown in this URL:https://www.mathworks.com/help/matlab/creating_plots/move-group-of-objects-along-line.html
The following code is the my try to realize my target. But it just can animate a line in coordinate system:
clear;
theta = -pi/4:0.001:0; % cosine of 2*theta will be positive for this range
r = -sqrt(cos(2*theta));
figure;
polarplot(theta, r, 'b', 'LineWidth',1.0);
hold on
h = animatedline;
rlim([0 1]);
h.LineWidth = 1.5;
h.LineStyle = ":";
h.Color=[1 0 0] ;
n= length(theta);
for k = 1:length(theta)
addpoints(h,theta(k),r(k))
drawnow
end
0 comentarios
Respuesta aceptada
Sulaymon Eshkabilov
el 10 de Feb. de 2023
Here it is:
clear;
theta = -pi/4:0.001:0; % cosine of 2*theta will be positive for this range
r = -sqrt(cos(2*theta));
figure;
polarplot(theta, r, 'b', 'LineWidth',1.0);
hold on
H = animatedline('Marker', 'o', 'MaximumNumPoints',1);
for k = 1:length(theta)
addpoints(H,theta(k),r(k));
drawnow
end
2 comentarios
Más respuestas (1)
Sulaymon Eshkabilov
el 10 de Feb. de 2023
Here is the corrected plot that animates a marker.
clear;
theta = -pi/4:0.001:0; % cosine of 2*theta will be positive for this range
r = -sqrt(cos(2*theta));
figure;
polarplot(theta, r, 'b', 'LineWidth',1.0);
hold on
H = animatedline('Marker', 'o');
rlim([0 1]);
n= length(theta);
for k = 1:n
addpoints(H,theta(k),r(k))
drawnow
end
Ver también
Categorías
Más información sobre Polar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


