0% found this document useful (0 votes)
3 views

Chapter 4

Uploaded by

Syed Sadiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter 4

Uploaded by

Syed Sadiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Chapter 4: Polar Coordinates in

MATLAB & Integration Using Polar


Coordinates

Author

image here
Converting Polar Coordinates to Rectangular
Converting Rectangular Coordinates to Polar
Plotting Polar Coordinates

Outline
Polar and Rectangular Coordinates

Every point can be expressed in:


Rectangulat coordinates: (x,y)
Polar coordinates: (r,θ)

3
Conversion Between Polar and Rectangular

Polar to Rectangular Rectangular to Polar

X = r cosθ r=

Y = r sinθ θ = tan-1()

4
Converting Between Polar And Cartesian in Matlab

>>[x,y] = pol2cart(pi/4,1)

x = ?
y = ?

>>[theta,r] = cart2pol(0,-4)

theta = ?
r = ?

[x,y] = pol2cart(theta,r)
[theta,r] = cart2pol(x,y)
angle comes first
5
Exercise

Calculate the
cartesian coordinates
of the two red points •

θ is expressed in radians

6
Polar Command in Matlab

The Matlab command:


 >> polar (theta,r,s);

Plots the points defined in polar coordinates as (r,theta) for all


values of r and theta
s is a string that defines the style of the plot
Ex: ‘y’: yellow | ‘r’: red

Reminder: theta must be in radians

7
Example 1

Use MATLAB to plot the following points in polar coordinates:


r=5, θ=0° | r=5, θ=60° | r=3, θ=180° | r=3, θ=300° | r=3,
θ=-30°

Solution:
Create a script file: example1.m

>> r=[5 5 3 3 3];


>> theta=[0 60 180 300 -30]*pi/180; %Convert to radians
>> polar(theta , r, 'x');

8
9
Example 2 Solution:
Find the polar coordinates of a >>x=3;
point (x,y) of your choice using >>y=4;
Matlab as a calculator >>r=sqrt(x^2+y^2);
>>theta=atan2(y,x); % in radians
>>theta = theta *180/pi % in degrees

Answer:
r=?
theta=?

10
Example 3 Solution:
Find the rectangular coordinates of >>r=5;
the point (5,53°) using Matlab as a >>theta=53*pi/180; %convert to radians
calculator >>x = r * cos(theta);
>>x = r * sin(theta);

Answer:
x=3
y=4

11
Example 3 Solution:
Repeat Example 1 and plot the Open a script file example1d.m
given points using the polar to >>r=[5 5 3 3 3];
rectangular conversion relation. >>theta=[0 60 180 300 -30]*pi/180;%to rad
Add the two examples on one plot. >>polar(theta,r,’x’);
>>hold on;
>>x=r .* cos(theta); % from polar to rectangular

>>y=r .* sin(theta); % from polar to rectangular

>>plot(x,y, ‘o’);

12
13
Example 5

Using Matlab, draw the curve r = sin(θ)

Solution:
Open a script file example5.m

theta=linspace(0,2*pi,200); %generates 200 points between 0 and 2π


r=sin(theta);
polar(theta,r,’r’);

14
15
Example 6

Using Matlab, draw the curve r = cos(2θ)

Solution:
Open a script file example6.m

>>theta=linspace(0,2*pi,200); %generates 200 points between 0 and 2π


>>r=cos(2*theta);
>>polar(theta,r,’r’);

16
17
Area in Polar Coordinates (from calculus II)

The area bounded by the curves r1(θ) , r2(θ), θ = θ1 and θ = θ2 is given


by: 2
1 2 2
Area  (r 2  r )d
1
2 1 θ1 and θ2 must be in radians

Example 7:
Find the area bounded by the curves r = 2 sinθ, θ1 = 45°, θ2 = 135°
and the origin
Show all curves in one plot

18
Solution (1/2)

1-plot the 3 curves


Open script file example7.m
>>theta=linspace(0,2*pi); %or theta=0:2*pi/100:2*pi;
>>r=2*sin(theta);
>>polar(theta,r,’r’); %plots r=2 sin(theta)
>>hold on;

>>r=linspace(0,2);
>>theta=(45*pi/180)*ones(size(r));
>>polar(theta,r,’b’);
>>hold on;

>>r=linspace(0,2);
>>theta=(135*pi/180)*ones(size(r));
>>polar(theta,r,’g’);

19
Solution (2/2)

2-form the integration and put the limits:


3
2 
1 2 2 1 4
Area  (r 2  r 1 ) d Area  ( 4 sin 2
  0)d
2 1 2


4

3-Go to command window of MATLAB and do the integration using int:


>>syms theta;
>>area=eval(0.5 * int(4 * sin(theta)^2 , pi/4 , 3*pi/4))
Answer:
area=?
20
Example 8

Determine the area of the region that lies inside


r= 3 +2 sinθ and r=2, show the region

Solution
1-plot the two curves:
Open example8.m
>>theta=linspace(0,2*pi)
>>r=2*ones(size(theta));
>>polar(theta,r,’r’);
>>hold on;
>>r=3+2*sin(theta);
>>polar(theta,r);

21
Solution (2/2)

2-form the integration and put the limits:


7
2 
1 2 2 1 6
Area  (r 2  r 1 ) d Area  [( 3  2 sin  ) 2
 4]d
2 1 2
 

6

3-Go to command window of MATLAB and do the integration using int:


>>syms theta;
>>area=eval(0.5*int((3+2*sin(theta))^2-4,-pi/6,7*pi/6))
Answer:
area=?
22

You might also like