[英]Plotting a 2D vector field with a 3D matrix quiver -MATLAB
I am having real trouble with vectors/matrices etc. in matlab. 我在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. 我有一个3D向量nxmx2,其中n是我的x坐标,m是我的y坐标,对于每个(x,y),都有两个z值,第一个是我在x方向上的速度,第二个是我的x方向y方向的速度。
How do I plot these velocity functions on a xy graph? 如何在xy图上绘制这些速度函数? 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
的正确方法是
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. 如果要使绘图轴的等距值不同于1,2,...
,则应使用meshgrid
生成它们,如quiver
文档中的示例所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.