Wind rose with no degrees for direction

3 次查看(过去 30 天)
I am trying to plot a wind rose but for direction I only have N, NE, NNE etc rather than degrees. Is there a code or script for this?
  3 个评论
Torsten
Torsten 2025-2-26
编辑:Torsten 2025-2-26
Usually you start with E = (1,0) as 0°, goto N = (0,1) as 90°, goto W = (-1,0) as 180°, goto S = (0,-1) as 270°.
The coordinates can then be obtained by the cosd and sind functions:
[cosd(0),sind(0)]
ans = 1×2
1 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[cosd(90),sind(90)]
ans = 1×2
0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[cosd(180),sind(180)]
ans = 1×2
-1 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[cosd(270),sind(270)]
ans = 1×2
0 -1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
But you are right: I just found that the relation between angle and direction seems to be different for wind roses:

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2025-2-26
Let's make some random direction data.
directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
n = numel(directions);
angles = 0:45:315;
randomDirections = directions(randi(n, 1, 10));
Now we can convert those strings into the corresponding angles.
[~, indices] = ismember(randomDirections, directions);
correspondingAngles = angles(indices);
And now we can show the results as a table so you can check.
results = table(randomDirections.', correspondingAngles.', VariableNames = ["dir", "angle"])
results = 10x2 table
dir angle ____ _____ "N" 0 "N" 0 "NE" 45 "W" 270 "N" 0 "S" 180 "S" 180 "NW" 315 "NE" 45 "E" 90

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by