简体   繁体   中英

Plotting a 2D vector field with a 3D matrix quiver -MATLAB

I am having real trouble with vectors/matrices etc. in matlab.

I have a 3D vector nxmx2 where n is my x-coordinate, m is my y-coordinate and for each (x,y) there are two z values, the first being my velocity in the x-direction, and the second being my velocity in the y-direction.

How do I plot these velocity functions on a xy graph? I have been trying with things like:

quiver(A)
quiver(A,A,A(:,:,1),A(:,:,2))

But can't seem to get it to work.

The correct way to use quiver for the input you describe is

quiver(A(:,:,1), A(:,:,2));

If you want the axes of the plot to have equal-spaced values different than 1,2,... you should use meshgrid to generate them, as shown in the examples in the quiver documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM