Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mean direction

Subject: mean direction

From: ClauDe

Date: 31 May, 2011 09:07:04

Message: 1 of 7

Hey everyone,

I need to calculate the mean direction from ocean current measurements.
I tried sth with "atan", but never got the result I was expecting (because of the timeseries plot). I expect sth like 300° but got sth like 120°...

What data do I have?
DIR (6768x1 double)
Speed (6768x1 double)
V (6768x1 double)
U (6768x1 double)

In hope someone can give me another look into this, cause I'm getting kind of confused about it...

Thanks in advance!!

Subject: mean direction

From: Rune Allnor

Date: 31 May, 2011 09:43:58

Message: 2 of 7

On May 31, 11:07 am, "ClauDe " <acerxen...@hotmail.com> wrote:
> Hey everyone,
>
> I need to calculate the mean direction from ocean current measurements.
> I tried sth with "atan", but never got the result I was expecting (because of the timeseries plot). I expect sth like 300° but got sth like 120°...
>
> What data do I have?
> DIR (6768x1 double)
> Speed (6768x1 double)
> V (6768x1 double)
> U (6768x1 double)
>
> In hope someone can give me another look into this, cause I'm getting kind of confused about it...

The result is wrong; it should obviously be 123.4 degrees.

Seriously, what kind of response do you expect to get?
You don't say anythiong about how these data have been
measured, what the variables represent, how you have
got your first result, or why you expect the result
you indicate.

Or defined what you mean by the term 'mean direction'.

Answer the questions indicated above (not so much for us
as for yourself), and you might eventually be getting
somewhere.

Rune

Subject: mean direction

From: ClauDe

Date: 31 May, 2011 10:21:04

Message: 3 of 7

> The result is wrong; it should obviously be 123.4 degrees.
>
> Seriously, what kind of response do you expect to get?
> You don't say anythiong about how these data have been
> measured, what the variables represent, how you have
> got your first result, or why you expect the result
> you indicate.
>
> Or defined what you mean by the term 'mean direction'.
>
> Answer the questions indicated above (not so much for us
> as for yourself), and you might eventually be getting
> somewhere.
>
> Rune

hey Rune,

ok, lets see.
I have data of the current directions and velocities from moored Currentmeter. The data start point is Nov2009 and end is Aug2010.
With these data I plotted a stickplot(drawn by currentvelocity and direction), that indicates/shows an average direction towards the South-East (by eye). I also plotted these data as a PVD (progressive vector diagram) which makes "pseudo trajectories" and it shows an South-East direction as well (by eye).

Now, I have to plot the mooring position into a bathymetry plot and on that plot I have to draw an arrow which is constructed out of the mean direction and mean velocity(length of this arrow), so to speak the average values.
This arrow shall indicate what the mean flow is and where it's going.

Ok, I could draw it by eye but I have to use the average values. Average of direction makes a little problem.

What I hoped to get here is an equation or sth. for MATLAB to calculate the average direction out of a Vector with directions that were measured on a mooring.

I tried:
rad = 2*pi/360
dirvecmean=atan2(umean,vmean);
dirmean1=dirvecmean / rad;

But this gives me an North-west direction which is not what I saw on my plots... that's why I'm confused!

Did that help at all? Or did I confused you even more with that? ;-)
Anyway, thanks for your help!

Subject: mean direction

From: Rune Allnor

Date: 31 May, 2011 10:26:01

Message: 4 of 7

On May 31, 12:21 pm, "ClauDe " <acerxen...@hotmail.com> wrote:
> > The result is wrong; it should obviously be 123.4 degrees.
>
> > Seriously, what kind of response do you expect to get?
> > You don't say anythiong about how these data have been
> > measured, what the variables represent, how you have
> > got your first result, or why you expect the result
> > you indicate.
>
> > Or defined what you mean by the term 'mean direction'.
>
> > Answer the questions indicated above (not so much for us
> > as for yourself), and you might eventually be getting
> > somewhere.
>
> > Rune
>
> hey Rune,
>
> ok, lets see.
> I have data of the current directions and velocities from moored Currentmeter. The data start point is Nov2009 and end is Aug2010.
> With these data I plotted a stickplot(drawn by currentvelocity and direction), that indicates/shows an average direction towards the South-East (by eye). I also plotted these data as a PVD (progressive vector diagram) which makes "pseudo trajectories" and it shows an South-East direction as well (by eye).

Ok, four questions:

1) Where is the reference direction (phi = 0) on the compass?
2) Where is the reference direction (phi = 0) in polar coordinates?
3) How does the vector change when dphi > 0 on the compass?
4) How does the vector change when dphi > 0 in polar corodinates?

Rune

Subject: mean direction

From: TideMan

Date: 31 May, 2011 10:57:51

Message: 5 of 7

On May 31, 10:21 pm, "ClauDe " <acerxen...@hotmail.com> wrote:
> > The result is wrong; it should obviously be 123.4 degrees.
>
> > Seriously, what kind of response do you expect to get?
> > You don't say anythiong about how these data have been
> > measured, what the variables represent, how you have
> > got your first result, or why you expect the result
> > you indicate.
>
> > Or defined what you mean by the term 'mean direction'.
>
> > Answer the questions indicated above (not so much for us
> > as for yourself), and you might eventually be getting
> > somewhere.
>
> > Rune
>
> hey Rune,
>
> ok, lets see.
> I have data of the current directions and velocities from moored Currentmeter. The data start point is Nov2009 and end is Aug2010.
> With these data I plotted a stickplot(drawn by currentvelocity and direction), that indicates/shows an average direction towards the South-East (by eye). I also plotted these data as a PVD (progressive vector diagram) which makes "pseudo trajectories" and it shows an South-East direction as well (by eye).
>
> Now, I have to plot the mooring position into a bathymetry plot and on that plot I have to draw an arrow which is constructed out of the mean direction and mean velocity(length of this arrow), so to speak the average values.
> This arrow shall indicate what the mean flow is and where it's going.
>
> Ok, I could draw it by eye but I have to use the average values. Average of direction makes a little problem.
>
> What I hoped to get here is an equation or sth. for MATLAB to calculate the average direction out of a Vector with directions that were measured on a mooring.
>
> I tried:
> rad = 2*pi/360
> dirvecmean=atan2(umean,vmean);
> dirmean1=dirvecmean / rad;
>
> But this gives me an North-west direction which is not what I saw on my plots... that's why I'm confused!
>
> Did that help at all? Or did I confused you even more with that? ;-)
> Anyway, thanks for your help!

Twice you've referred to sth:
"I expect sth like 300° ...."
"What I hoped to get here is an equation or sth. ....."

I analyse ADP/ADCP current records just about every week, but I've
never heard of a "sth"
What is it?

Getting average direction is simply:
angle(mean(v+i*u))*pi/180 degrees from North
But you may need to correct for magnetic N, which is what most current
meters measure.
Where I live, the correction to get True North is 23.4 deg, which is
quite significant.

Note: you cannot simply average the direction, you must average the
complex current vector, then convert to direction.

Subject: mean direction

From: ClauDe

Date: 31 May, 2011 12:53:03

Message: 6 of 7

Hey TideMan,

thanks a lot.
Now the result is as I thought it should be! :-)

Take care

Subject: mean direction

From: Roger Stafford

Date: 31 May, 2011 17:45:05

Message: 7 of 7

"ClauDe" wrote in message <is2obf$ev6$1@newscl01ah.mathworks.com>...
> Hey TideMan,
>
> thanks a lot.
> Now the result is as I thought it should be! :-)
>
> Take care
- - - - - - - - - -
  There is another possibility. It depends on whether you wish to weight your mean computation by the strength of the wind or not. If you do, then Tideman's solution is the right way to proceed. If all winds are to be weighted equally independent of their intensity, you should do this:

 d = 180/pi*angle(mean((v+i*u)./abs(v+i*u)))

  You can also get the same result with

 r = sqrt(u.^2+v.^2);
 d = 180/pi*atan2(mean(u./r),mean(v./r));

  As Tideman indicates, you should never attempt to take the mean value of angles. It will lead to nonsense.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us