在Matlab中轮廓化网格并分配大小箭头 [英] Contouring a mesh and assigning magnitude arrows in Matlab

查看:160
本文介绍了在Matlab中轮廓化网格并分配大小箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将矢量分配给Contourf图,以显示风的方向和大小. 为此,我使用的是contourf(A)quiver(x,y),其中A是矩阵151x401,x,y是大小和方向都相同的大小(151x401)的矩阵.

I want to assign vector to a contourf graph, in order to show the direction and magnitude of wind. For this I am using contourf(A) and quiver(x,y), where as A is a matrix 151x401 and x,y are matrices with the same sizes (151x401) with magnitude and direction respectively.

当我使用大型地图时,我会得到箭头的位置,但必须将其固定放置,这会使图形看起来很糟糕.

When I am using large maps i get the position of the arrows but they are to densily placed and that makes the graph look bad.

最后一个图形具有所需的箭头,但是它们与许多箭头过于接近,我希望它们更加稀缺和分布,并且它们之间的间隙更大,以便能够增加它们的长度和同时使等高线图的组件可见.

The final graph has the arrows as desired, but they are to many of them and too close, I would like them to be more scarce and distributed with more gap between them, so as to be able to increase their length and at the same time have the components of the contour map visible.

任何人都可以帮忙,任何指针都会有所帮助

Can anyone help , any pointers would be helpful

推荐答案

我知道问了这个问题已经有很长时间了,但是我想我找到了一种使它起作用的方法. 如果有人遇到相同的问题,我会附上代码

i know its been a long time since the question was asked, but i think i found a way to make it work. I attach the code in case someone encounters the same issues

[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

A,B,C是要使用的对应矩阵

A,B,C are the corresponding matrices ones want to use

这篇关于在Matlab中轮廓化网格并分配大小箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆