3
votes

As title

I only have the theta/rho data

the line equation is

x*cos(theta)+y*sin(theta)=rho

how to plot line whith these data in matlab?

are there any function which input are theta and rho?

thanks

2
I think the answer is in your question - simply plot the equation x*cos(theta)+y*sin(theta)=rho after throwing in your theta and rho values and rearranging to y = ... EDIT: use this to plot the equation mathworks.com.au/help/matlab/ref/fplot.html - user993683

2 Answers

4
votes

Just use some simple Algebra to find out how y is related to x.
Take some range for x:

 x = -10:10;
 y = (rho - x* cos(theta) )/ sin(theta);
 plot(x,y)
1
votes

You can just use the built in polar function

polar(theta,rho) creates a polar coordinate plot of the angle theta versus the radius rho. theta is the angle from the x-axis to the radius vector specified in radians; rho is the length of the radius vector specified in dataspace units.

You can also transform polar to cartesian with pol2cart() then use the regular plot(x,y) function.

[X,Y] = pol2cart(THETA,RHO) transforms the polar coordinate data stored in corresponding elements of THETA and RHO to two-dimensional Cartesian, or xy, coordinates. The arrays THETA and RHO must be the same size (or either can be scalar). The values in THETA must be in radians.

There is also a cart2pol() function that does the reverse transformation.

[THETA,RHO] = cart2pol(X,Y) transforms two-dimensional Cartesian coordinates stored in corresponding elements of arrays X and Y into polar coordinates.