How to make a discrete x-y plot with quiver instead of stem

Hi,
I'm a matlab newbie. I made a simple X-Y plot with the stem command:
x=linspace(-10,10); x= -10:1:10; a= [0,0,0,0,0,0,0,0,0.5,0,0,0,0.5,0,0,0,0,0,0,0,0];
stem(x,a);
grid on;
But I'd like to get rid of the "circles" (points with y=0) and also add arrows to the vertical lines at x=-1 and x=+1).
I tried to use the quiver command without success. Can someone post some sample code using quiver (or stem if quiver can't do this)?
Thank you.

 Respuesta aceptada

A Jenkins
A Jenkins el 13 de Sept. de 2013
Editada: A Jenkins el 13 de Sept. de 2013
Using quiver() as requested:
x= -10:1:10;
a= [0,0,0,0,0,0,0,0,0.5,0,0,0,0.5,0,0,0,0,0,0,0,0];
y=zeros(size(x));
v=zeros(size(x));
% yaxis matches but "ugly" arrowhead
figure(1)
quiver(x,y,v,a,0)
% yxis does not match but better arrowhead
figure(2)
quiver(x,y,v,a,2)
Compare figure(1) and figure(2). If you care about the arrowhead size versus y-axis scaling, you may want to check out the file exchange for a solution:

Más respuestas (0)

Categorías

Más información sobre Vector Fields en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

Kim
el 13 de Sept. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by