Wind rose plotting issue
7 views (last 30 days)
Show older comments
I've tried to plot the following wind rose problem bu I can not get the right answer. Please advise how to do this problem. I am working on this code. Why can't I obtain the rose provided?
clc
clear all
close all
v=[5 15 4; 1 0 0; 13 5 3; 7 0 0; 10 1 2; 11 0 0; 19 2 1; 1 0 0]; %Percentage of winds
d=[0 0 0; 45 45 45; 90 90 90; 135 135 135; 180 180 180; 225 225 225; 270 270 270; 315 315 315]; %Wind directions
% v = sort(v); %Wind speeds
% d=[0 30 60 90 120 150 180 210 240 270 300 330 ]; %Wind directions
%Execute wind rose function
wind_rose_Example(d,v)
function wind_rose_Example(wind_direction,wind_speed)
%WIND_ROSE Plot a wind rose
% this plots a wind rose
figure
pax = polaraxes;
polarhistogram(deg2rad(wind_direction(wind_speed<47)),deg2rad(0:10:360),'FaceColor','red','displayname','31 - 47 MPH')
hold on
polarhistogram(deg2rad(wind_direction(wind_speed<31)),deg2rad(0:10:360),'FaceColor','yellow','displayname','15 - 31 MPH')
polarhistogram(deg2rad(wind_direction(wind_speed<15)),deg2rad(0:10:360),'FaceColor','green','displayname','4 - 15 MPH')
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'top';
legend('Show')
title('Wind Rose')
%to add percentages
% numberOfMeasurement = sum(wind_speed<20);
% p = 1:10;
% rticks(p/100*numberOfMeasurement)
% rticklabels(strcat(string(p),'%'))
% rlim([0 10/100*numberOfMeasurement])
end
0 Comments
Accepted Answer
VBBV
on 7 Apr 2023
Edited: VBBV
on 7 Apr 2023
v=[5 15 4; 1 0 0; 13 5 3; 7 0 0; 10 1 2; 11 0 0; 19 2 1; 1 0 0]; %Percentage of winds
d=[0 0 0; 45 45 45; 90 90 90; 135 135 135; 180 180 180; 225 225 225; 270 270 270; 315 315 315]; %Wind directions
% v = sort(v); %Wind speeds
% d=[0 30 60 90 120 150 180 210 240 270 300 330 ]; %Wind directions
%Execute wind rose function
wind_rose_Example(d,v)
function wind_rose_Example(wind_direction,wind_speed)
%WIND_ROSE Plot a wind rose
% this plots a wind rose
figure
pax = polaraxes;
polarhistogram(deg2rad(wind_direction(wind_speed<47 & wind_speed >= 31)),deg2rad(0:30:360),'FaceColor','red','displayname','31 - 47 MPH')
hold on
polarhistogram(deg2rad(wind_direction(wind_speed<31 & wind_speed >= 15)),deg2rad(0:30:360),'FaceColor','yellow','displayname','15 - 31 MPH')
polarhistogram(deg2rad(wind_direction(wind_speed<15 & wind_speed >= 4)),deg2rad(0:30:360),'FaceColor','green','displayname','4 - 15 MPH')
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'top';
legend('Show')
title('Wind Rose')
%to add percentages
% numberOfMeasurement = sum(wind_speed<20);
% p = 1:10;
% rticks(p/100*numberOfMeasurement)
% rticklabels(strcat(string(p),'%'))
% rlim([0 10/100*numberOfMeasurement])
end
Add a condition for wind_speed range in the polarhistogram function like this
polarhistogram(deg2rad(wind_direction(wind_speed<47 & wind_speed > 31)),deg2rad(0:30:360),'FaceColor','red','displayname','31 - 47 MPH')
Hope this helps
0 Comments
More Answers (0)
See Also
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!