How to make a discrete x-y plot with quiver instead of stem
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
A Jenkins
2013년 9월 13일
편집: A Jenkins
2013년 9월 13일
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:
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Vector Fields에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!