Professional Documents
Culture Documents
quiver
Quiverorvelocityplot
Syntax
quiver(x,y,u,v)
quiver(u,v)
quiver(...,scale)
quiver(...,LineSpec)
quiver(...,LineSpec,'filled')
quiver(...,'PropertyName',PropertyValue,...)
quiver(axes_handle,...)
h=quiver(...)
Description
Aquiverplotdisplaysvelocityvectorsasarrowswithcomponents(u,v)atthepoints(x,y).
Forexample,thefirstvectorisdefinedbycomponentsu(1),v(1)andisdisplayedatthepointx(1),y(1).
quiver(x,y,u,v)plotsvectorsasarrowsatthecoordinatesspecifiedineachcorrespondingpairofelementsinxandy.
Thematricesx,y,u,andvmustallbethesamesizeandcontaincorrespondingpositionandvelocitycomponents.
However,xandycanalsobevectors,asexplainedinthenextsection.Bydefault,thearrowsarescaledtojustnot
overlap,butyoucanscalethemtobelongerorshorterifyouwant.
quiver(u,v)drawsvectorsspecifiedbyuandvatequallyspacedpointsinthexyplane.
quiver(...,scale)automaticallyscalesthearrowstofitwithinthegridandthenstretchesthembythefactorscale.
scale=2doublestheirrelativelength,andscale=0.5halvesthelength.Usescale=0toplotthevelocityvectors
withoutautomaticscaling.YoucanalsotunethelengthofarrowsaftertheyhavebeendrawnbychoosingthePlotEdit
tool,selectingthequiverobject,openingthePropertyEditor,andadjustingtheLengthslider.
quiver(...,LineSpec)specifieslinestyle,markersymbol,andcolorusinganyvalidLineSpec.quiverdrawsthe
markersattheoriginofthevectors.
quiver(...,LineSpec,'filled')fillsmarkersspecifiedbyLineSpec.
quiver(...,'PropertyName',PropertyValue,...)specifiespropertynameandpropertyvaluepairsforthequiver
objectsthefunctioncreates.
quiver(axes_handle,...)plotsintotheaxeswiththehandleaxes_handleinsteadofintothecurrentaxes(gca).
h=quiver(...)returnsthehandletothequiverobject.
ExpandingxandyCoordinates
MATLABexpandsxandyiftheyarenotmatrices.Thisexpansionisequivalenttocallingmeshgridtogenerate
matricesfromvectors:
https://in.mathworks.com/help/matlab/ref/quiver.html 1/4
9/26/2016 QuiverorvelocityplotMATLABquiverMathWorksIndia
[x,y]=meshgrid(x,y);
quiver(x,y,u,v)
Inthiscase,thefollowingmustbetrue:
length(x)=nandlength(y)=m,where[m,n]=size(u)=size(v).
Thevectorxcorrespondstothecolumnsofuandv,andvectorycorrespondstotherowsofuandv.
Examples collapseall
PlotVectorVelocities
Usequivertodisplayanarrowateachdatapointinxandysuchthat
thearrowdirectionandlengthrepresentthecorrespondingvaluesinu OpenScript
andv.
[x,y]=meshgrid(0:0.2:2,0:0.2:2);
u=cos(x).*y;
v=sin(x).*y;
figure
quiver(x,y,u,v)
ShowGradientwithQuiverPlot
Plotthegradientofthefunction .
OpenScript
https://in.mathworks.com/help/matlab/ref/quiver.html 2/4
9/26/2016 QuiverorvelocityplotMATLABquiverMathWorksIndia
[X,Y]=meshgrid(2:.2:2);
Z=X.*exp(X.^2Y.^2);
[DX,DY]=gradient(Z,.2,.2);
figure
contour(X,Y,Z)
holdon
quiver(X,Y,DX,DY)
holdoff
MoreAbout
CombineContourPlotandQuiverPlot
SeeAlso
Functions
contour|LineSpec|plot|quiver3
Properties
QuiverSeriesProperties
IntroducedbeforeR2006a
https://in.mathworks.com/help/matlab/ref/quiver.html 3/4
9/26/2016 QuiverorvelocityplotMATLABquiverMathWorksIndia
https://in.mathworks.com/help/matlab/ref/quiver.html 4/4