Mat Ginny Vogginio
Mat Ginny Vogginio

Reputation: 57

average wind direction using histc matlab

Hello this question might be easy but i am struggling to get average wind directions for 1 year. I need hourly averages to compare with concentration measurements. My wind measurements are every minute in degree. So my idea was to use the histc function in matlab to get the most common winddirection within the hour. this works for 1 h but how do i create a loop which gives me hourly values for a year.

here is the code

wdd=winddirections in degree(vectorsize e.g for a year 525600)

binranges = [0:10:360];

[bincounts,ind] = histc(wdd(1:60),binranges);
[num idx] = max(bincounts(:));
wd_out=binranges(idx);

kind regards matthias

Upvotes: 0

Views: 434

Answers (2)

Divakar
Divakar

Reputation: 221614

How about this one -

binranges = [0:10:360]
[bincounts,ind]  = histc(reshape(wdd,60,[]),binranges)
[nums idxs] = max(bincounts)
wd_out=binranges(idxs)

Upvotes: 1

Ander Biguri
Ander Biguri

Reputation: 35525

What I would do is:

wdd_phour=reshape(wdd,60,525600/60);  % get a matrix of size 60(min) X hours per year
mean_phour=mean(wdd_phour,1);         % compute the average of each 60 mins for every our in a year

Upvotes: 1

Related Questions