我有一个数据文件,其中包括风速和风向(如下所示)。
数据:
Date & Time Wind speed wind direction
1/1/2013 0:00 3.81 196.97
1/1/2013 6:00 4.18 216.86
1/1/2013 12:00 2.84 10.95
1/1/2013 18:00 2.67 26.15
1/2/2013 0:00 2.68 359.15
1/2/2013 6:00 2.54 34.52
1/2/2013 12:00 3.65 41.86
1/2/2013 18:00 1.94 84.80
1/3/2013 0:00 1.51 83.81
1/3/2013 6:00 1.87 162.18
1/3/2013 12:00 2.99 104.94
1/3/2013 18:00 2.74 170.23
我想用箭头和幅度绘制这个时间序列,如下图所示 你介意帮我吗?
答案 0 :(得分:3)
我给你一个使用箭袋的例子,箭头接受一个x和y向量,这样你就可以把你的日期作为x向量。
close all
len = 50; %size of the smaple
date = exp(linspace(1,5,len)) %random date
speed = linspace(0,2,len)'; %speed vector
direction = linspace(0,360,len)'; %direction vector
direction = ((direction/360)*4*pi)-2*pi %[0-360] to [-2*pi,2*pi]
[u,v] = pol2cart(direction,speed); %polar to cartesian coordinate
%we plot the result
quiver(date, zeros(size(u)), u, v); %quiver(x,y,u,v), where y = zeros(size(u))
hold on
%we add a central line
plot(date,zeros(size(u)))
要将日期转换为矢量,您应该使用函数datenum
<强>结果:强>