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:
Increments and angle of a vector

Subject: Increments and angle of a vector

From: Konst

Date: 15 Oct, 2012 15:10:07

Message: 1 of 3

I have two time-series x and y with sampling rate 1sample/sec. I want to compute the increments of those two every 1sec (a moving window maybe but how?) and then assuming that x's increments are lying along the x-axis and y's increments along the y-axis I want to plot the angle of the resulting vector. But how can I compute the angle of a vector? I don't even know how to do it in maths. Any ideas?

Subject: Increments and angle of a vector

From: Barry Williams

Date: 15 Oct, 2012 16:56:09

Message: 2 of 3

"Konst " <konstance1@hotmail.com> wrote in message <k5h90f$4th$1@newscl01ah.mathworks.com>...
> I have two time-series x and y with sampling rate 1sample/sec. I want to compute the increments of those two every 1sec (a moving window maybe but how?) and then assuming that x's increments are lying along the x-axis and y's increments along the y-axis I want to plot the angle of the resulting vector. But how can I compute the angle of a vector? I don't even know how to do it in maths. Any ideas?

Think Cartesian plot with an origin at 0,0, which is one apex of your right triangle. The x,y coordinates form another apex, with x(n),0 forming the base at the bottom of the right angle. Get it now?
If you need the angle at each point, do the basic trigonetry to get the angle. That's your answer.
If you want the mean vector, do a least squares fit, perhaps with a force to zero, a=X\Y.
This sounds a bit like a homework problem. If you want more help, show some additional effort.
Barry

Subject: Increments and angle of a vector

From: Roger Stafford

Date: 15 Oct, 2012 19:40:20

Message: 3 of 3

"Konst " <konstance1@hotmail.com> wrote in message <k5h90f$4th$1@newscl01ah.mathworks.com>...
> I have two time-series x and y with sampling rate 1sample/sec. I want to compute the increments of those two every 1sec (a moving window maybe but how?) and then assuming that x's increments are lying along the x-axis and y's increments along the y-axis I want to plot the angle of the resulting vector. But how can I compute the angle of a vector? I don't even know how to do it in maths. Any ideas?
- - - - - - - - - - -
  Calling your increments dx and dy their angle can be calculated by:

 ang = atan2(dy,dx);

or alternatively

 ang = angle(dx+dy*i); % <-- where 'i' is the square root of -1

Roger Stafford

Tags for this Thread

No tags are associated with 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