ayk
ayk

Reputation: 1497

How do I draw 2D Map with plot() in MATLAB

I am trying to create a 2D map of some place. I get a 181x1 vector of laser sensor readings from a robot. All the values in this vector corresponds to a distance from that single angle like 1°,2°..180°. The problem here is I need to create a map by plotting these distances as dots with plot() or a similar function to it.

Upvotes: 0

Views: 2570

Answers (3)

yuk
yuk

Reputation: 19870

You can convert your angle-distance coordinates to Cartesian X and Y with POL2CART function.

[X,Y] = pol2cart((1:180)/180*pi, distanceVector);

Then you can use PLOT.

plot(X,Y,'.')

Upvotes: 2

kennytm
kennytm

Reputation: 523304

plot(theVector, '.')

if you need to plot as dots instead of lines. If the dot is too small, try to plot as circles.

plot(theVector, 'o')

See http://www.mathworks.com/access/helpdesk/help/techdoc/ref/linespec.html for detail.

Upvotes: 1

second
second

Reputation: 28637

there is a function for plotting in polar coordinates. try

>> polar( (0:180)/180*pi, distanceVector)

Upvotes: 4

Related Questions