matlab quiver()画箭头的函数
p1 = [2 3]; % First Point p2 = [9 8]; % Second Point dp = p2-p1; % Difference figure(1) quiver(p1(1),p1(2),dp(1),dp(2),0) grid axis([0 10 0 10]) text(p1(1),p1(2), sprintf('(%.0f,%.0f)',p1)) text(p2(1),p2(2), sprintf('(%.0f,%.0f)',p2))
调整箭头大小的代码:
quiver(x0,y0,x1,y1,'MaxHeadSize',0.05,'AutoScaleFactor',0.89,'AutoScale','off');
h = quiver ... set(h,'autoscalefactor',2); 调节这个数可以改变箭头的长度。
quiver(mean(y),mean(x),2,0,'r','filled','LineWidth',1.5,'MaxHeadSize',2,'AutoScaleFactor',10); text(mean(y)+20,mean(x),'y=sin(x)');