SUNY Geneseo Department of Mathematics
Math 230 02
Spring 2015
Prof. Doug Baldwin
Complete by Wednesday, February 18
Grade by Monday, February 23
This lesson establishes a basic ability to draw graphs with Matlab. It also introduces parametric equations as an interesting mathematical idea with applications for generating a wide variety of interesting curves.
Attaway introduces 2-dimensional plotting in section 3.5 of her text. The Edinburgh video lecture on “ Creating a Simple Plot” covers similar material, with a nice summary of how to do some of it interactively. The video lecture on “ Creating a Simple Script” is also relevant—even though it is mainly about writing scripts, the example it uses is a script that plots a circle.
The concept of a “parametric curve” or set of “parametric equations” is central to graphing in Matlab, and to lots of other computer graphics. You can find an introduction to (or review of, if you’ve seen them before) parametric equations in the “Parametric Curves—Basic Graphing” video at https://www.youtube.com/watch?v=tsnHL1Lb5MU.
Write Matlab scripts to solve each of the following problems. Both problems have several parts, so writing scripts with one “%%” section per part will help you test each part separately of the others:
The parametric equations
x(t) = cost
y(t) = sint
generate a circle when plotted with t ranging from 0 to 2π. Explain in words how/why this happens. Then write a Matlab script that plots the curve. It will be most obviously circular if your plot has square axes—i.e., 1 unit on the x axis is the same length on screen as 1 unit on the y axis.
What determines the radius of the circle generated by these equations? Test your ideas by extending your script to plot two concentric circles with different radii. (For a bit of extra challenge, have the script prompt the user for the circles’ radii each time it runs. Also see if you can make the circles different colors.)
Finally, think about how you would plot an ellipse (hint: the ellipse’s axes can be parallel to the x and y axes). Try your ideas by extending your circle script to plot an ellipse. Be sure that your ellipse looks elliptical when plotted with square axes, i.e., that the elliptical appearance isn’t just due to non-uniform axes.
Try to devise parametric equations that describe each of the following kinds of spiral:
Once you think you have equations for the two kinds of spiral, write a Matlab script based on your equations and test it to see if it draws the expected sorts of spiral (if not, is the problem in your equations, or in your code? how would you know?) Put some thought into selecting values of a and the number of turns to draw for both spirals so that you can be reasonably certain that your code and equations are correct.
The Spirograph (legally a trademark of Hasbro) toy produces very elaborate curves that are technically known as hypotrochoids and epitrochoids. Not surprisingly, these curves can also be described by parametric equations. The Wikipedia article on Spirographs has a good treatment of the mathematics of the Spirograph that derives these equations. Use them to write a Matlab script that simulates a Spirograph. Your script will need parameters (provided, e.g., through variables set in the command window before running the script or read from the user by the script when it runs) to provide the radii of the two wheels and the distance of the simulated pen point from the center of the inner wheel.
I will grade this exercise in a face-to-face meeting with you. During this meeting I will look at your solution, ask you any questions I have about it, answer questions you have, etc. Please bring a written solution to the exercise to your meeting, as that will speed the process along.
Sign up for a meeting via Google calendar. If you worked in a group on this exercise, the whole group should schedule a single meeting with me. Please make the meeting 15 minutes long, and schedule it to finish before the end of the “Grade By” date above.