How to use feather, quiver or stickplot for wind direction timeseries?

37 次查看(过去 30 天)
I need to do a plot like the figure but I don´t know which function plot to use. I have the wind direction in degrees and the wind speed in m/s. I want the xtick to be the date.
Thank you!

回答(2 个)

Sai Pavan
Sai Pavan 2023-9-27
Hi Daniela,
I understand that you are trying to figure out which of the plot functions to use to plot the wind direction timeseries data in the format shown in the uploaded figure.
The quiverfunction can be used to plot the wind direction timeseries data so that the arrows originate from x-axis and creates quiver plots, which represent wind direction as arrows with lengths and directions proportional to wind speed and direction respectively. The X-axis represents the time and xtick" can be set to date.
Please refer to the below documentation to know more about the quiver” function:
https://www.mathworks.com/help/matlab/ref/quiver.html
Here's a reference code to plot the quiver plot of wind speed and direction data:
figure;
quiver(time, zeros(size(time)), windSpeed.*sind(windDirection), windSpeed.*cosd(windDirection));
title('Quiver Plot');
xlabel('Time');
ylabel('Wind Direction (degrees)');
axis tight;
Hope it helps.
Regards,
Sai Pavan
  1 个评论
indika kathaluwa weligamage
Hi Sai Pavan
Thank your answer. It is very very important for me too.
I tried but result not like the expected. (As requested in first question)
Could you please futher explain.
A set of ample data and my cord are attached herewith for your kind consideration.
Thanks,INDIKA
load jan.txt;
windDirection=jan(:,5);
windSpeed=jan(:,4);
time=jan(:,1);jan(:,2);jan(:,3);
%time=power_2022(:,1:3);%
figure;
quiver(time, zeros(size(time)), windSpeed.*sind(windDirection), windSpeed.*cosd(windDirection));
2022 1 1 58.5 4.39
2022 1 2 62.81 5.99
2022 1 3 69.56 5.83
2022 1 4 67 4.88
2022 1 5 110.44 2.09
2022 1 6 78.25 3.9
2022 1 7 69.69 4.26
2022 1 8 40.31 3.02
2022 1 9 58.81 3.69
2022 1 10 118.62 2.11
2022 1 11 125.12 2.11
2022 1 12 163.56 2.31
2022 1 13 197.88 2.56
2022 1 14 126.88 1.77
2022 1 15 75.06 1.72
2022 1 16 55.69 4.48
2022 1 17 62.5 5.11
2022 1 18 61.44 4.14
2022 1 19 44.81 4.49
2022 1 20 130.12 2.73
2022 1 21 255.25 1.59
2022 1 22 216 1.54
2022 1 23 141.62 1.45
2022 1 24 120.94 1.8
2022 1 25 93.25 2.52
2022 1 26 60.5 2.71
2022 1 27 49.88 3.48
2022 1 28 76.25 3.53
2022 1 29 108.25 3.03
2022 1 30 90.44 3.49
2022 1 31 76.75 4.6

请先登录,再进行评论。


Madmad
Madmad 2024-9-18
A bit late but had the same issue, figured it out so if someone needs a code to do it:
% Number of months (5 years)
numMonths = 60;
u = randn(numMonths, 1) * 10;
v = randn(numMonths, 1) * 10;
windSpeed = sqrt(u.^2 + v.^2);
years = repmat(2002:2006, 1, 12);
yearIndices = 1:12:numMonths;
figure;
hold on;
for i = 1:numMonths
xStart = i;
yStart = 0;
uComponent = u(i);
vComponent = v(i);
quiver(xStart, yStart, uComponent, vComponent, 0, 'k', 'LineWidth', 2, 'MaxHeadSize', 2, 'AutoScale', 'off');
end
yLimits = [-max(windSpeed), max(windSpeed)];
yTicks = -10:2:10;
for y = yTicks
if y >= yLimits(1) && y <= yLimits(2)
yline(y, '--k');
end
end
yline(0, '-k');
set(gca, 'YTick', yTicks);
set(gca, 'XTick', yearIndices);
set(gca, 'XTickLabel', arrayfun(@(x) num2str(x), ...
years(yearIndices), 'UniformOutput', false));
xlabel('Year');
ylabel('Wind Speed (m/s)');
title('Monthly Wind Speed for 5 Years');
grid on;
hold off;

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by