How to Plot Fermat's Spiral in MATLAB

Written by eric smith
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Plot Fermat's Spiral in MATLAB
Different types of spirals are found throughout nature. (Hemera Technologies/ Images)

Fermat's spiral is a special type of Archimedean spiral. Archimedean spirals are described by the equation r = a * (theta^(1/n)), where "r" is the radial distance, "theta" is the polar angle and "n" is a constant that alters how tightly the spiral is wrapped. When n = 2, r^2 = a^2 * theta, and the spiral is called Fermat's spiral. For any given positive value of theta, there are two values of "r": r = a * (theta^(1/2)) and r = -a * (theta^(1/2)). This results in a symmetrical spiral about the origin.

MATLAB is a software application developed by MathWorks for technical computing. Many scientists and engineers use MATLAB to perform data analysis and data visualisation. You can use MATLAB to plot Fermat's spiral.

Skill level:
Moderately Easy

Other People Are Reading


  1. 1

    Type "a = 2" in the Command window.

  2. 2

    Type "theta = 0:(2pi)/100:(10pi)" to generate a range of values of "theta."

  3. 3

    Type "r_pos = a * (theta.^(1/2))" to calculate the positive value of "r" for each value of "theta."

  4. 4

    Type "r_neg = -a * (theta.^(1/2))" to calculate the negative value of "r" for each value of "theta."

  5. 5

    Type "polar(theta,r_pos,'k-')" to plot the positive part of the spiral on polar coordinates in black.

  6. 6

    Type "hold on, polar(theta,r_neg,'r-')" to plot the negative part of the spiral on the same polar coordinates in red.

Tips and warnings

  • You can also plot Fermat's spiral on Cartesian coordinates instead of polar coordinates. Once you have calculated your values of "theta," "r_pos" and "r_neg," convert them to Cartesian coordinates using the "Pol2cart" function, e.g. "[x_pos, y_pos] = pol2cart(theta,r_pos)." Then plot the points using the "Plot" function, e.g. type "plot(x_pos, y_pos)." Repeat the same steps for the positive part of Fermat's spiral.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.