David Norman
David Norman

Reputation: 301

How does 'quiver' function work in matlab?

How does the quiver function work? I know it creates vector arrows but what do u,v,x and y variables actually mean?

Upvotes: 1

Views: 2665

Answers (2)

George
George

Reputation: 128

I had a similar question, and with some advice i managed to overlap contours and quiver I have posted the code in the answers (Contouring a mesh and assigning magnitude arrows in Matlab)

take a look it may be of help to you as well

[nx,ny]= size(A) % A is the matrix used as base
xx=1:1:ny; % set the x-axis to be equal to the y
yy=1:1:nx; % set the y-axis to be equal to the x
contourf(xx,yy,A)
hold on, delta = 8; %delta is the distance between arrows)
quiver(xx(1:delta:end),yy(1:delta:end),B(1:delta:end,1:delta:end),C(1:delta:end,1:delta:end),1) % the 1 at the end is the size of the arrows
set(gca,'fontsize',12);, hold off

Upvotes: 1

Luis Mendo
Luis Mendo

Reputation: 112659

x, y are the horizontal and vertical coordinates of the origin of each vector.

u, v are the horizontal and vertical components of each vector. Thus the length of the vectors would be sqrt(u.^2 + v.^2). But there's a normalization in u, v so that maximum length is a nice value that avoids one vector overlapping (or getting into the "area" of) another vector.

Upvotes: 4

Related Questions