Calculating the directional and magnitude frequency of wind at spec... (2024)

9 views (last 30 days)

Show older comments

Jonathon Klepatzki on 7 Nov 2023

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles

Commented: Mathieu NOE on 15 Nov 2023

Accepted Answer: Mathieu NOE

  • windrose.pdf
  • WindRose.txt

I am trying to calculate the frequency of the wind direction and speed at specific angles to be used in a compass plot. I am receving an error that states "incorrect inputs or outputs when using the find function. I have attached the PDF of the code and the datafile to be used. Any help would be greatly appreciated.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Mathieu NOE on 8 Nov 2023

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#answer_1348627

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#answer_1348627

Edited: Mathieu NOE on 8 Nov 2023

Open in MATLAB Online

hello

well, your code looks a bit strange to me

first error is that find does not operate on table elements. You could have loaded directly your data as numeric data only with readmatrix (not need for readtable here)

then there are some lines wher the syntax makes me wonder where this code comes from :

% calculate specific direction based on frequency

N_freq = meanfreq(WNDIR,N_WND_IDX);

W_freq = meanfreq(WNDIR,W_WND_IDX);

S_freq = meanfreq(WNDIR,S_WND_IDX);

E_freq = meanfreq(WNDIR,E_WND_IDX);

I am not aware of a meanfreq function that has 2 input arguments (??)

also

U =

sum(W_freq(S_WSPD_freq,M_WSPD_freq,W_WSPD_freq,WW_WSPD_freq,C_WSPD_freq),E_freq...

(S_WSPD_freq,M_WSPD_freq,W_WSPD_freq,WW_WSPD_freq,C_WSPD_freq))

V =

sum(N_freq(S_WSPD_freq,M_WSPD_freq,W_WSPD_freq,WW_WSPD_freq,C_WSPD_freq),S_freq...

(S_WSPD_freq,M_WSPD_freq,W_WSPD_freq,WW_WSPD_freq,C_WSPD_freq))

wonder what this is supposed to do ... what are you trying to do ? what is the math behind this ?

at the end I wonder why you need to reinvent the wheel as they are already good stuff available on the FEX for wind rose plotting

let's pick this one :

wind_rose(wind_direction,wind_speed) - File Exchange - MATLAB Central (mathworks.com)

and this is the result obtained in less than 1 minute of work

Calculating the directional and magnitude frequency of wind at spec... (3)

Tbl = readmatrix('WindRose.txt');

WNDIR = Tbl(:,6); % pulling wind direction data from column 6

WSPD = Tbl(:,7); % pulling wind speed data from column 7

wind_rose(WNDIR,WSPD); % see function below

%%%%%% FEX : https://fr.mathworks.com/matlabcentral/fileexchange/65174-wind_rose-wind_direction-wind_speed

function wind_rose(wind_direction,wind_speed)

%WIND_ROSE Plot a wind rose

% this plots a wind rose

figure

pax = polaraxes;

polarhistogram(deg2rad(wind_direction(wind_speed<25)),deg2rad(0:10:360),'displayname','20 - 25 m/s')

hold on

polarhistogram(deg2rad(wind_direction(wind_speed<20)),deg2rad(0:10:360),'FaceColor','red','displayname','15 - 20 m/s')

polarhistogram(deg2rad(wind_direction(wind_speed<15)),deg2rad(0:10:360),'FaceColor','yellow','displayname','10 - 15 m/s')

polarhistogram(deg2rad(wind_direction(wind_speed<10)),deg2rad(0:10:360),'FaceColor','green','displayname','5 - 10 m/s')

polarhistogram(deg2rad(wind_direction(wind_speed<5)),deg2rad(0:10:360),'FaceColor','blue','displayname','0 - 5 m/s')

pax.ThetaDir = 'clockwise';

pax.ThetaZeroLocation = 'top';

legend('Show')

title('Wind Rose')

end

8 Comments

Show 6 older commentsHide 6 older comments

Jonathon Klepatzki on 8 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953687

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953687

Edited: Jonathon Klepatzki on 8 Nov 2023

Hey Matt,

I appreciate the help. I am 'relatively new' to coding despite taking one class during my undergrad. Therefore, I spend time writing and figuring out what works and doesn't work while developing something.

The attempt with frequency is to find how often specific wind directions occur (work demands). Any suggestions?

I also need to extract time from the file (datetime, I think would be good), any suggestions?

I am trying to do one thing. How can we extract data from a specific set of rows and plot it using wind rose? For example, use data from row 2751:2798). I tried it just now and got an error ("index must not exceed 18 or index in position 2 exceeds array bounds")

(Don't ask about the sum code, it was an experimental attempt).

I also appreciate the help with the code you provided as I found the wind rose function and couldn't quite get it to work.

Mathieu NOE on 8 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953752

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953752

hello again

ok, I understand you wanted to create your own code and not rely on someone else code (including the wind rose function)

now this is a work that is maybe a bit tough for someone just starting coding so I wonder what kind of result you need to provide

IMO what you have to do is to create a histogram , but here it would be nice to have it in polar coordinates and that's exactly what polarhistogram can provide

so I wonder why someone needs to reinvent this function or if you are allowed to use it

Mathieu NOE on 8 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953767

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953767

also I still don't have the answer about where does your meanfreq function comes from ? seems not in the standard matlab package (the only one I am aware comes from the Signal Processing Toolbox and has only one input argument : Mean frequency - MATLAB meanfreq - MathWorks France

Jonathon Klepatzki on 8 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953792

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953792

Edited: Jonathon Klepatzki on 8 Nov 2023

Yeah, it's a challenge for sure. I'm actually being forced to learn Python as I go (no excuse is allowed here at my particular position).

Before I found the wind rose code, is why I tried to develop my own. However, if I can find someone else's code that does what I need, I will gladly use it.

Ultimately, what I need is the number of times and count of (frequency) specific wind directions occurred (e.g., 330 degrees occurred x amount of times at time x on the 1st of January) at a given sector. Do that for the entire 24-hr period of January 1st. The follow-up will then do that for every single day and plot each one.

Jonathon Klepatzki on 13 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2959702

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2959702

@Mathieu NOE,

Can you verify my results from this code? I rewrote the main body to the following:

x = readmatrix('WindRose.txt')

WNDIR = x(2:2798,6);

WSPD = x(2:2798,7);

[C,ia] = unique(WNDIR)

W = WNDIR(ia,:)

[S,ia1] = unique(WSPD)

M = WSPD(ia1,:)

wind_rose(W,M)

I'm hoping that the unique function allows me to plot the windrose given the number of times a specific DIR and magnitude occurs beginning with the first row (row 2). On my end, the code works. I just would like a professional overview. Thanks!

Mathieu NOE on 14 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2960377

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2960377

Open in MATLAB Online

hello again

a few suggestions to improve your code (don't forget also the ; at the end of each line , otherwise you fill your command window with the content of each variable that appears in the line)

I wonder if applying unique is a good thing , why only plot unique events ? if the wind blows often at the same speed and / or direction, why hide this is the plot ?

x = readmatrix('WindRose.txt');

ind = (2:2798); % create once the rows indice and use it as many times as needed (reduce risk of bad manual input)

WNDIR = x(ind,6);

WSPD = x(ind,7);

[WNDIR,ia] = unique(WNDIR); % you have alreay the "new" WNDIR in the function output

WSPD = WSPD(ia,:); % don't forget to apply the ia selection to WSPD as well

[WSPD,ia] = unique(WSPD); % you have alreay the "new" WSPD in the function output

WNDIR = WNDIR(ia,:); % don't forget to apply the ia selection to WNDIR as well

wind_rose(WNDIR,WSPD);

Jonathon Klepatzki on 14 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2960952

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2960952

Thank you for the tip! I was hoping that the unique function would do the following:

  • count the number of times a specific wind direction occurred (count) at a specific zone (e.g. 0 or 360 is zone 1)
  • calculate the frequency those winds occurred
  • plot the wind rose
  • disp or print the chart of the results

Mathieu NOE on 15 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2961722

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2961722

well that's exactly the contrary, unique will remove all duplicates so in terms of statistics your are not taking into account the most frequent events and you will miss that in your plot

what you need to do is an histogram (see histcount) and that's what is doing the wind_rose function with polarhistogram

Sign in to comment.

More Answers (1)

Sakshi Sharma on 8 Nov 2023

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#answer_1348622

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#answer_1348622

Open in MATLAB Online

find isn't going to work on a table, but it will work on the contents of a table. So in this case you can write:

W_WND_IDX = find(WNDIR.WDIR < 330 & WNDIR.WDIR > 210);

1 Comment

Show -1 older commentsHide -1 older comments

Jonathon Klepatzki on 8 Nov 2023

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953692

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/2044237-calculating-the-directional-and-magnitude-frequency-of-wind-at-specific-angles#comment_2953692

Hi Sakshi,

That's awesome, I appreciate the help. I gotta figure out how to frequencies now.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D Plots

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

  • compass
  • frequency
  • find

Products

  • MATLAB Coder

Release

R2023a

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Calculating the directional and magnitude frequency of wind at spec... (14)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Calculating the directional and magnitude frequency of wind at spec... (2024)

FAQs

What is the formula for calculating wind direction? ›

The wind direction can be calculated using trigonometric functions: Angle = arctan(V/U), this is valid as long as U is not equal to zero. You must also adjust for what quadrant you are in based on whether U and V are positive or negative.

How do you calculate wind frequency? ›

The number of times that a range ∆M of wind speeds occurred in the past is the frequency of occurrence. Dividing the frequency by the total number of wind measurements gives a relative frequency.

How to determine wind direction? ›

Meteorologists study the strength and the direction of wind. One tool they use for measuring wind direction is a wind vane. It spins and points in the direction from which the wind is blowing. The wind can blow in every direction, but in many places most winds will blow in the same general direction.

What is the math for wind direction? ›

md = 270 − wwd

where md is the "math" wind direction, and wwd is the "weather wind direction". If the value is less than zero, just add 360. Note that using our math wind direction, a due west wind will have a vector pointing along the x-axis and thus a direction of zero degrees.

What is the frequency of the wind? ›

The wind frequency is the percentage of the time the wind is coming from a particular direction, and should be obtained from the nearest weather station. This data can be obtained from National Climatic Data Center.

How is frequency calculated? ›

In general terms frequency is determined by dividing the number of events by the time it took for the events. So if a wave travels past a certain point 4 times in one second, then the frequency is 4 times/1 second, or 4 Hz.

How to calculate the average wind direction? ›

Averaging Wind Direction and Speed is done by splitting out the East/West vector and the North/South vector. Each of these can be averaged then recombined to produce a speed and a direction. Some Wind Sensors will already provide the split Uvector and Vvector which saves a step.

What is the rule for wind direction? ›

Question: Which law states that the wind blows towards the right in the northern hemisphere? Ferrel's Law: Winds in the northern hemisphere are deflected to the right, while winds in the southern hemisphere are deflected to the left. Ferrel's Law is another name for this.

What are the two methods to find out wind direction at a given place? ›

Answer: Two methods to find out wind direction at a given place are (i) An instrument called anemometer can be used to find the direction and speed of the wind. (ii) Hold a strip of paper outside. The direction in which the paper is blowing, is the direction in which the wind blows.

What is the formula for wind? ›

Wind speed is calculated as follows: Instantaneous Wind Speed = Anemometer Factor x Instantaneous Shaft Speed. Average Wind Speed = Anemometer Factor x (Number of Turns / Time)

How do you reference wind direction? ›

The wind direction is based on true north orientation and is the direction the wind is blowing from. For example, a northerly wind is blowing from the north towards the south. Wind speed and direction can be influenced significantly by the local environment.

What is the resultant wind direction? ›

Resultant Wind Direction is measured in degrees compass. Resultant wind direction values are obtained by converting the 5-minute wind speeds and directions for the hour into a single hourly vector. Resultant wind direction is the direction of this vector.

How can you determine the direction of the wind answer? ›

A variety of instruments can be used to measure wind direction, such as the anemoscope, windsock, and wind vane. All these instruments work by moving to minimize air resistance. The way a weather vane is pointed by prevailing winds indicates the direction from which the wind is blowing.

How do you calculate wind direction from angle? ›

Math Wind Convention

The magnitude of UH is UH = (u2 + v2)1/2. The math wind angle, α, is the angle of the wind relative to the x-axis, so that tan(α) = v/u and the angle increases counterclockwise as the direction moves from the eastward x-axis (α = 0o) to the northward y-axis (α = 90o) .

How do you calculate direction? ›

The direction of a vector formula is related to the slope of a line. We know that the slope of a line that passes through the origin and a point (x, y) is y/x. We also know that if θ is the angle made by this line, then its slope is tan θ, i.e., tan θ = y/x. Hence, θ = tan-1 (y/x).

What is the formula for wind analysis? ›

The formula for wind load is F = A x P x Cd x Kz x Gh, where A is the projected area, P is wind pressure, Cd is the drag coefficient, Kz is the exposure coefficient, and Gh is the gust response factor.

References

Top Articles
Vegan Shakshuka Recipe
5 Delicious, Easy Vegan Recipes That Cost $5 Or Less
Menards Thermal Fuse
San Angelo, Texas: eine Oase für Kunstliebhaber
Get train & bus departures - Android
Es.cvs.com/Otchs/Devoted
DENVER Überwachungskamera IOC-221, IP, WLAN, außen | 580950
Owatc Canvas
Umn Pay Calendar
Lesson 1 Homework 5.5 Answer Key
Dark Souls 2 Soft Cap
You can put a price tag on the value of a personal finance education: $100,000
2135 Royalton Road Columbia Station Oh 44028
Newgate Honda
Robert Malone é o inventor da vacina mRNA e está certo sobre vacinação de crianças #boato
‘Accused: Guilty Or Innocent?’: A&E Delivering Up-Close Look At Lives Of Those Accused Of Brutal Crimes
Cooking Fever Wiki
Belly Dump Trailers For Sale On Craigslist
Games Like Mythic Manor
I Touch and Day Spa II
Weather Rotterdam - Detailed bulletin - Free 15-day Marine forecasts - METEO CONSULT MARINE
Craigslist Southern Oregon Coast
Great Clips Grandview Station Marion Reviews
Rs3 Ushabti
Bellin Patient Portal
Sherburne Refuge Bulldogs
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
California Online Traffic School
Sand Dollar Restaurant Anna Maria Island
2011 Hyundai Sonata 2 4 Serpentine Belt Diagram
Lovindabooty
O'reilly's In Monroe Georgia
Astro Seek Asteroid Chart
Housing Intranet Unt
Smartfind Express Henrico
Www Violationinfo Com Login New Orleans
Clark County Ky Busted Newspaper
The Vélodrome d'Hiver (Vél d'Hiv) Roundup
Instafeet Login
Tiny Pains When Giving Blood Nyt Crossword
Publictributes
Orion Nebula: Facts about Earth’s nearest stellar nursery
Wrigley Rooftops Promo Code
Mugshots Journal Star
Ig Weekend Dow
فیلم گارد ساحلی زیرنویس فارسی بدون سانسور تاینی موویز
Interminable Rooms
Tropical Smoothie Address
Horseneck Beach State Reservation Water Temperature
Concentrix + Webhelp devient Concentrix
David Turner Evangelist Net Worth
Texas Lottery Daily 4 Winning Numbers
Latest Posts
Article information

Author: Duane Harber

Last Updated:

Views: 5796

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Duane Harber

Birthday: 1999-10-17

Address: Apt. 404 9899 Magnolia Roads, Port Royceville, ID 78186

Phone: +186911129794335

Job: Human Hospitality Planner

Hobby: Listening to music, Orienteering, Knapping, Dance, Mountain biking, Fishing, Pottery

Introduction: My name is Duane Harber, I am a modern, clever, handsome, fair, agreeable, inexpensive, beautiful person who loves writing and wants to share my knowledge and understanding with you.