Matlab绘制方向和速度矢量图

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

%% =======绘制方向和速度矢量图=======

%compass-绘制罗盘图

%feather-绘制羽毛图

%quiver-绘制二维箭头图

%quiver3-绘制三维箭头图

%绘制罗盘图

figure;

wdir=[45 90 90 45 360 335 360 270 335 270 335 335];

knots=[6 6 8 6 3 9 6 8 9 10 14 12];

rdir=wdir*pi/180;

[x,y]=pol2cart(rdir,knots);% 极坐标转化为直角坐标

compass(x,y);

title('风向和风力')

%绘制羽毛图

figure;

alpha=90:-10:0;

r=ones(size(alpha));

m=alpha*pi/180;

n=r*10;

[u,v]=pol2cart(m,n);% 极坐标转化为直角坐标

feather(u,v);

title('羽毛图')

%罗盘图和羽毛图的比较

figure;

t=-pi/2:pi/12:pi/2; % 在 区间,每 取一点。

r=ones(size(t)); % 单位半径

[x,y]=pol2cart(t,r); % 极坐标转化为直角坐标

subplot(1,2,1),compass(x,y),title('Compass')

subplot(1,2,2),feather(x,y),title('Feather')

%绘制箭头图

figure;

[x,y] = meshgrid(-2:.2:2,-1:.15:1);

z = x .* exp(-x.^2 - y.^2);

[px,py] = gradient(z,.2,.15);

subplot(1,2,1);

contour(x,y,z), hold on

quiver(x,y,px,py), hold off, axis image

title('quiver示例');

[x,y,z]=peaks(15);

[nx,ny,nz]=surfnorm(x,y,z);%surfnorm求平面的法向量

subplot(1,2,2)

surf(x,y,z);

hold on;

quiver3(x,y,z,nx,ny,nz);

title('quiver3示例');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天天Matlab科研工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值