
draw a circle point-by-point with a spiral path
5 views (last 30 days)
Show older comments
I need a matlab program to draw a circle point-by-point with a spiral path, I have center and radius coordinates
0 Comments
Answers (1)
Yash
on 20 Jul 2025
Refer to below code snippet to draw a spiral that starts from the circle's center and stops at the circumference.
xc = 5; % x-coordinate of center of circle
yc = 7; % y-coordinate of center of circle
r = 4; % radius of circle
theta_max = 6*pi; % turns in spiral, spiral reaches radius at theta_max
n_points = 1000; % points in spiral
t = linspace(0, theta_max, n_points);
max_r_spiral = r;
a = 0;
b = max_r_spiral / theta_max;
% Spiral path (polar coordinates)
spiral_r = a + b * t;
spiral_x = xc + spiral_r .* cos(t);
spiral_y = yc + spiral_r .* sin(t);
figure;
hold on;
axis equal;
plot(xc, yc, 'ko', 'MarkerFaceColor','k');
theta = linspace(0, 2*pi, 200);
plot(xc + r*cos(theta), yc + r*sin(theta), 'k--'); % reference circle
for k = 1:n_points
plot(spiral_x(k), spiral_y(k), 'ro', 'MarkerSize', 3, 'MarkerFaceColor','r');
pause(0.01);
end
title('Circle point-by-point with a Spiral Path');

0 Comments
See Also
Categories
Find more on Language Fundamentals 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!