How to make a discrete x-y plot with quiver instead of stem
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
A Jenkins
le 13 Sep 2013
Modifié(e) : A Jenkins
le 13 Sep 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:
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Vector Fields dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!