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

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 measure the direction of the wind? ›

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 formula for wind pressure? ›

Wind pressure is obtained from wind velocity, and the drag coefficient depends on the shape. Example: A cylindrical tower, 6m diameter, faces a wind of 40 m/s. Wind Pressure = 0.613 x (Wind Speed)^2 = 0.613 x 40^2 ≈ 980 N/m².

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

The way a weather vane is pointed by prevailing winds indicates the direction from which the wind is blowing. The larger opening of a windsock faces the direction that the wind is blowing from; its tail, with the smaller opening, points in the same direction as the wind is blowing.

What is the math for wind direction? ›

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) .

What is the frequency of 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 do I calculate my frequency? ›

If the wavelength is given, the formula to find frequency is speed of the wave divided by the wavelength. If the speed of a wave is 6 m/s and the wavelength is 2 m, then the frequency is 6 /2 = 3 Hz.

How do you find the frequency of a wind instrument? ›

For an open/closed pipe, the fundamental frequency is f=v/(4L).

How can we guess the direction of the wind? ›

If you happen to own a weather vane, remembering this rule should be easy because a wind vane points into the wind and thus toward the direction FROM which the wind blows. So, wind direction is always the direction from which the wind is blowing.

What tool is used to measure wind direction? ›

In meteorology, an anemometer (from Ancient Greek άνεμος (ánemos) 'wind' and μέτρον (métron) 'measure') is a device that measures wind speed and direction. It is a common instrument used in weather stations.

What is the formula for measuring wind? ›

V=Q/{(D/2)^2*3.14*3600} V-wind speed (m/s); Q-air volume (m3/h);

What is the mathematical equation for wind power? ›

We'll start with a 6 m/s wind. The power in the wind at 6 m/s is: 1/2 x ρ x A x v3 = 0.5 x 1.225 kg/m3 x 452.4 m2 x (6 m/s)3 = 59,851 W = 59.85 kW.

How to calculate the force of wind? ›

Armed with pressure and drag data, you can find the wind load using the following formula: force = area x pressure x Cd. Using the example of a flat section of a structure, the area – or length x width – can be set to 1 square foot, resulting in a wind load of 1 x 25.6 x 2 = 51.2 psf for a 100-mph wind.

How do you find prevailing wind direction? ›

The best way to determine the direction of prevailing winds at your home or business is to document the wind direction each day for a period of time. You can do this by setting up a weather vane or simply going outside and stand facing into the wind.

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).

How to calculate wind direction from U and V in Excel? ›

ws = sqrt(u2+v2)

To get the direction, we turn again to trigonometry. We have x and y (u and v), and we want an angle. This will require the inverse trig function of tan -- eg, arctan(v/u).

References

Top Articles
Craigslist Farm And Garden Santa Barbara
C Programming Language Tutorial - GeeksforGeeks
Kem Minnick Playboy
Frederick County Craigslist
Fredatmcd.read.inkling.com
Teamexpress Login
Lycoming County Docket Sheets
Corporate Homepage | Publix Super Markets
Citymd West 146Th Urgent Care - Nyc Photos
Directions To 401 East Chestnut Street Louisville Kentucky
Arre St Wv Srj
Roster Resource Orioles
Fraction Button On Ti-84 Plus Ce
Apply for a credit card
Mccain Agportal
*Price Lowered! This weekend ONLY* 2006 VTX1300R, windshield & hard bags, low mi - motorcycles/scooters - by owner -...
Understanding Genetics
Atdhe Net
Tu Pulga Online Utah
Egizi Funeral Home Turnersville Nj
What Time Does Walmart Auto Center Open
Slim Thug’s Wealth and Wellness: A Journey Beyond Music
Devotion Showtimes Near Regency Buenaventura 6
Gma' Deals & Steals Today
NV Energy issues outage watch for South Carson City, Genoa and Glenbrook
30+ useful Dutch apps for new expats in the Netherlands
Winterset Rants And Raves
Downloahub
3473372961
Taktube Irani
Mg Char Grill
Darrell Waltrip Off Road Center
Vanessa West Tripod Jeffrey Dahmer
Zero Sievert Coop
Bianca Belair: Age, Husband, Height & More To Know
Ashoke K Maitra. Adviser to CMD&#39;s. Received Lifetime Achievement Award in HRD on LinkedIn: #hr #hrd #coaching #mentoring #career #jobs #mba #mbafreshers #sales…
Gary Lezak Annual Salary
Lcwc 911 Live Incident List Live Status
Wasmo Link Telegram
Emily Tosta Butt
FedEx Authorized ShipCenter - Edouard Pack And Ship at Cape Coral, FL - 2301 Del Prado Blvd Ste 690 33990
40X100 Barndominium Floor Plans With Shop
Bismarck Mandan Mugshots
25100 N 104Th Way
How To Win The Race In Sneaky Sasquatch
How To Connect To Rutgers Wifi
Ok-Selection9999
Texas 4A Baseball
Códigos SWIFT/BIC para bancos de USA
Latest Posts
Article information

Author: Kelle Weber

Last Updated:

Views: 6250

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Kelle Weber

Birthday: 2000-08-05

Address: 6796 Juan Square, Markfort, MN 58988

Phone: +8215934114615

Job: Hospitality Director

Hobby: tabletop games, Foreign language learning, Leather crafting, Horseback riding, Swimming, Knapping, Handball

Introduction: My name is Kelle Weber, I am a magnificent, enchanting, fair, joyous, light, determined, joyous person who loves writing and wants to share my knowledge and understanding with you.