24 plotting
Exercise 3: Simple 2 d plotting
Please save all the plots you produce using the File → Save option in the Figure
Window. This should save a file with theMATLABdefault Figure format
which uses a .fig file extension.
- Plot the following functions (you will need to decide on appropriate
ranges forx):- y=^1 x, with a blue dashed line.
- y=sin(x)cos(x), with a red dotted line.
- y=2x^2 −3x+ 1 , with red cross markers.
Turn thegrid onin all your plots, and remember to label axes and use
a title.
- Given the following function:
s=acos(φ) +
√
b^2 − (asin(φ) −c)^2
Plotsas a function of angleφwhena= 1 ,b= 1.5,c=0.3, and
06 φ 6360 ◦.
- Plot the following parametric functions (you will need to use the
axis equalcommand after yourplotcommand to forceMATLABto
make the x-axis and y-axis the same length):
a) A circle of radius 5 (revisit Ex2 Q7)
b) Leminscate (−π/4 6 φ 6 π/4)
x=cos(φ)
√
2cos(2φ)
y=sin(φ)
√
2cos(2φ)
c) Logarithmic Spiral ( 06 φ 6 6π;k=0.1)
x=ekφcos(φ)
y=ekφsin(φ)
Exercise 3 Solutions
(http://www.eng.ed.ac.uk/teaching/courses/matlab/unit02/Ex3-
Solutions.shtml)