Plotting a Curve in Polar Coordinates Using MATLAB

In summary, the conversation discusses using MATLAB to plot a graph using polar coordinates and finding the element of arc length along the curve for line integrals. The speaker also mentions using a parameterisation and solving the integral for theta. Ultimately, they were able to successfully plot the graph using MATLAB.
  • #1
morry
136
0
Ok, so I've been given a curve in polar coordinates.

I came up with a parameterisation:
x(t)=rcos(theta)
y(t)=rsin(theta)

But now I have to plot the graph using MATLAB and I have no idea. Theta lies between 0 and 2pi.

This is what I put in and got back in matlab:
>> t=[0:pi/50:2pi]
? t=[0:pi/50:2pi]
|
Error: Missing MATLAB operator.

Cheers.
 
Physics news on Phys.org
  • #2
Should that be 2*pi?
 
  • #3
Thanks Tide. I must still be doing something wrong.

The graph is archimedes spiral. r= theta

Heres what I've tried to do:

>>syms x y r theta
>>x=r*cos(theta)
>>y=r*sin(theta)
>>ezpolar(x,y)

I only need to plot from theta= 0-->2pi

Im really lost.

Any info on how to do line integrals would also be appreciated.

Thanks again.
 
  • #4
You need to find the element of arc length along the curve. This should help:

[tex]ds = \sqrt {dr^2 + r^2 d\theta^2}[/tex]

which you can easily integrate.
 
  • #5
Thanks Tide. I am not having trouble doing the maths by hand. I can find line integrals no worries by hand its just that I have no idea how to use matlab.
 
  • #6
morry,

Since [itex]r = \theta[/itex] you just need to evaluate the integral

[tex]\int_{0}^{2\pi} \sqrt{1+\theta^2} d\theta[/tex]

so look for a MatLab command resembling "int(sqrt(1+x^2), x = 0..2pi)"
 
  • #7
Thanks for the help again Tide, I think I've got it all out! Finally!
 

Related to Plotting a Curve in Polar Coordinates Using MATLAB

What is the process for plotting a curve in polar coordinates using MATLAB?

To plot a curve in polar coordinates using MATLAB, you will need to use the polarplot() function. This function takes in two inputs: the angle values (in radians) and the corresponding radius values. You can then customize the plot by adding a title, labels, and adjusting the color and style of the curve.

Can I plot multiple curves in polar coordinates on the same plot using MATLAB?

Yes, you can plot multiple curves on the same polar plot using MATLAB. Simply use the hold on command to prevent the previous plot from being overwritten. Then, use the polarplot() function to add each curve to the plot.

How do I convert cartesian coordinates to polar coordinates in MATLAB?

To convert cartesian coordinates to polar coordinates in MATLAB, you can use the cart2pol() function. This function takes in the x and y coordinates as inputs and returns the corresponding angle and radius values in radians.

What is the difference between a polar plot and a cartesian plot?

The main difference between a polar plot and a cartesian plot is the coordinate system used. A polar plot uses polar coordinates, where a point is determined by an angle and a radius, while a cartesian plot uses cartesian coordinates, where a point is determined by an x and y value. Additionally, polar plots typically display data in a circular or radial pattern, while cartesian plots display data on a rectangular grid.

Can I save a polar plot as an image file in MATLAB?

Yes, you can save a polar plot as an image file in MATLAB. You can use the saveas() function and specify the file type (e.g. .png, .jpg) to save the plot as an image. You can also use the print() function and specify the file type and resolution to save the plot as an image.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
311
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
Back
Top