Creating a shape with varying arcs?
Show older comments
I would like to create a circle-like shape, but with various arcs along the circumference. A better way to explain this is just explain an example.
For example, I want to start with a circle that has a radius of 2 inches, have it gradually grow out to 3 inches over "x" radians, stay at 3 inches for "y" radians, and then return to 2 inches over "z" radians. Is this possible to plot in MATLAB? I am not sure how I would go about getting equations for those arcs and putting them together in a piecewise fashion to display continuously. The center of this circle is irrelevant to the problem, so for simplicity I will say the center of the BASE circle (the 2 in circular arc) is the origin. Picture for reference:

Accepted Answer
More Answers (1)
Giorgos Papakonstantinou
on 6 Mar 2015
If I understood correctly you mean a spiral. Here's one way then:
turns=5;
theta = 0:pi/180:2*pi*turns;
r = 2*ones(size(theta));
r(theta>1 & theta<=4) = linspace(2, 3, sum(theta>1 & theta<=4)); % radius gradually grows from 1<theta<=4 rad
r(theta>4) = 3; % constant radius for 4 rad<theta<=6 rad
r(theta>6) = linspace(3, 20, sum(theta>6)); % radius gradually grows from 6 rad<theta
X=sin(theta).*r;
Y=cos(theta).*r;
plot(X,Y)
axis square
Of course you can adjust the radians as you wish.

1 Comment
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


