SUNY Geneseo Department of Mathematics
Math 230 01
Fall 2014
Prof. Doug Baldwin
Complete by Wednesday, October 1
Grade by Monday, October 6
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:
Plot the function y = 4 - x2 for -3 ≤ x ≤ 3. Do you consider that you defined the function as a set of parametric equations in order to plot it? Why or why not?
The parametric equations
x(t) = cos(t)
y(t) = sin(t)
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 writing a script that plots 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.)
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 Matlab scripts based on your equations and test them to see if they draw 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.