Rotating an ellipse in matlab

hm1

Junior Member
Jun 28, 2010
14
0
0
So I have a two part assignment, the first part is to plot the ellipse for

a) (x^2/9)+(y^2/4) = 1

I think I did this right as when i do plot (x,y) it displays an ellipse

b) draw the ellipse obtained by rotating (x^2/9)+(y^2/4) = 1 30 degrees
counterclockwise.
I can't for the life of me find a rotate command. I was hoping I could just rotate the plot I got from part a but there is no command to do that. anyone have ideas?

TIA
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Not a matlab user... but can you just put together a function to apply a rotation matrix to the list of points?
 

Net

Golden Member
Aug 30, 2003
1,592
2
81
I agree with Markbnj, try using a rotation matrix.

I can't tell you if this is going to work but you can try to solve for y: y = +- 2/3 * sqrt(9-x^2)

Then plug in points for x, 0, 1, 2, 3 this will contruct your xOld and yOld

then use a rotation matrix such as:

xNew = xOld * cos(angle * pi/180) - yOld * sin(angle * pi/180)
yNew = xOld * sin(angle * pi/180) + yOld * cos(angle * pi/180)

and plot the points xNew and yNew points.
 
Last edited:

hm1

Junior Member
Jun 28, 2010
14
0
0
Thanks guys I think that was it. I didn't know about the rotation matrix