# Plotting x,y coordinates and vectors with octave

I have a data set containing the recorded data from a car's motion (latitude,longitude, and heading). I'd like to plot the (lat,lon) points on a 2D plot with a unit vector pointing in the direction of the car's heading at each point. The heading is given in azimuth degrees so I think I would first have to convert that to radians then calculate the (x,y) point that represents the head of the unit vector.

I don't have any trouble plotting the (lat,lon) points but I have no idea about the vectors. I'm pretty new to Octave but I do know at least basic C/C++. An animated plot would be even better if anyone knows how to set that up.

The command you are likely looking for is quiver. It only does 2D vector field plots, and you may have to normalize your vector lengths yourself. It also requires that all of your points be on a rectangular grid, although there is likely a work around for that.

quiver(x, y, u, v);


For an animated plot, you want to draw a single location and vector(still using quiver) inside a loop and use the pause command for animation. Since this sounds a little like a homework problem I will leave the details to you.

• Thanks! It looks like Octave has a built in demo on quiver too. – JDD Sep 4 '12 at 13:17
• Actually, quiver seems to work with any list of points, not just a rectangular grid. – Bill Barth Sep 4 '12 at 13:17
• I have only played with the matlab version. I remembered fighting it to plot my polar data, but didn't remember the details of my difficulty. – Godric Seer Sep 4 '12 at 15:09