필터 지우기
필터 지우기

Wind rose plotting issue

조회 수: 3 (최근 30일)
juan sanchez
juan sanchez 2023년 4월 6일
편집: VBBV 2023년 4월 7일
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

채택된 답변

VBBV
VBBV 2023년 4월 7일
편집: VBBV 2023년 4월 7일
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개)

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by